sql中的select查询问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:49:45
请教高手,假如我用
select * from 表 where 字段='19840329';这是精确查询
那么select * from 表 where 字段 like '%1984%'这是模糊查询
问题:
假如我想查询某个字段里的数据由第几位到第几位之间的数据怎么查
例如:字段生日字段19840101 我想精确查询出0101的数据 怎么查?谢谢大家
问题已解决,虽然并没有采取你们的答案,不过很感谢你们,
我是这样解决的,select * from 表 where 字段 like '____0101'

其中下划线是在英文输入法下的下划线,每一个_代表一个字符,连续4个_代表1984,这样就会精确的查出含有0101的所有数据来了

select * from 表
where 字段 between '19840101' and '19841231'

这样就是1984年出生的人了

用截取字符串函数substring来实现吧。。
select * from 表 where substring(字段,5,4)='0101'

select * from 表 where substring(字段,5,4) like '0101'

select * from 表 where substring(字段,5,4)='0101'
意思是从这个字段的第5位开始取,取4位长度

select * from 表 where substring(字段,5,4)='0101'