假如我的表中有这么几个ID
我想查--查询学号倒数第二位为3--,
我就用了这个语句1 ,
select stuid from G_stuinfo
where stuid like '%3_' --这句是没有显示的,为什么呢?语句2
select stuid from G_stuinfo
where stuid like '___3_' --这个是因为我事先知道了ID是五位的,才写这个,可是呢,还是没有显示的。语句3
select stuid from G_stuinfo
where stuid like '___3%' --这个才能正确显示我想要的,可是这个表示的不是--学号倒数第二位为3--吧,
这个是什么啊,有没有那位大大满足我小小的心愿的!
我想查--查询学号倒数第二位为3--,
我就用了这个语句1 ,
select stuid from G_stuinfo
where stuid like '%3_' --这句是没有显示的,为什么呢?语句2
select stuid from G_stuinfo
where stuid like '___3_' --这个是因为我事先知道了ID是五位的,才写这个,可是呢,还是没有显示的。语句3
select stuid from G_stuinfo
where stuid like '___3%' --这个才能正确显示我想要的,可是这个表示的不是--学号倒数第二位为3--吧,
这个是什么啊,有没有那位大大满足我小小的心愿的!
select stuid from G_stuinfo
后是这个
mysql> SELECT 1230' LIKE '%3_';
-> 1------------------------------------------------------
另外:
In MySQL, LIKE is allowed on numeric expressions.
(This is an extension to the standard SQL LIKE.) mysql> SELECT 10 LIKE '1%';
-> 1
老师给我的题目里是char(10),只有在
select stuid from G_stuinfo
where stuid like '%3______' ---后面再加上五个空格才行,本来我想把老师的表改一下的,可是主键是不是不能通过
alter table G_stuinfo modify stuid varchar(10), 来改的,不让 改!