汽车钥匙能配普通的吗:关于SQL的一个问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/06 00:52:24
数据库里有一个名为observtimes的列,其中有很多如2006030201,2006030202,2005030201,2004050206等之类的值.我现在要显示以20060302开头的所有值.该怎么做呀????????????????

你说的2006030201,2006030202,2005030201,2004050206这些值是在一行记录里,还是分别在多行里呢?

如果每个值在ojservtimes里各占一行,那么

select observtimes
from 表
where observtimes like '20060302%'

楼上使用substring效率低。

select observtimes from 表名 where observtimes like '20060302%'

select observtimes from 表名 where substring(observtimes,1,8)=20060302

select * from 表名 where observtimes>2006000000 and observtimes<2007000000

select * from 表名 where observtimes like '2006%'

呵呵 不知道行不行