数据库表名为student
列名为sid(学号)
想要查询几个指定部分学号的学生信息
select * from student where sid like '%[x,x,x,x-x]%'
但是上面的语句中,在方刮号[ ] 中只能是单个字符"X"或者是"x-x"范围,
但在方刮号[ ] 中输入字符串
select * from student where sid like '%[xx,xxx,xx,xx-xx]%'
查询不到正确的结果
列名为sid(学号)
想要查询几个指定部分学号的学生信息
select * from student where sid like '%[x,x,x,x-x]%'
但是上面的语句中,在方刮号[ ] 中只能是单个字符"X"或者是"x-x"范围,
但在方刮号[ ] 中输入字符串
select * from student where sid like '%[xx,xxx,xx,xx-xx]%'
查询不到正确的结果
where sid like '%[xx,xxx,xx]%' or sid between xx and yy
http://topic.csdn.net/u/20090419/12/0ac13557-83a4-4319-94ff-dff95f8f4e4f.html
IF object_id('tb') IS NOT NULL
DROP TABLE tb
GOCREATE TABLE tb(v VARCHAR(200))
GOINSERT tb SELECT 'vvabdd'
UNION ALL SELECT 'vvbcdd'
UNION ALL SELECT 'vva'
UNION ALL SELECT 'vv'
GOSELECT * FROM tb WHERE v LIKE '%[ab,bc]%'
GO/*
vvabdd
vvbcdd
vva --这条记录的出线就说明问题了。*/
----------------------------------
LIKE '5[%]' 5%
LIKE '[_]n' _n
LIKE '[a-cdf]' a、b、c、d 或 f
LIKE '[-acdf]' -、a、c、d 或 f
LIKE 'abc[def]' abcd、abce 和 abcf