select的模糊查询 急急!!!!
id names
1 20070430116020-zxm-.wav
2 20070430114641-aa-13273118119.wav
3 20070430114521-bb-15901279833.wav
4 20070530114621-aa-.wav
5 20070612114621-cc-13985698745.wav
6 20070410114621-cc-83626987.wav
7 20070420114621-ee-83628874.wav
8 20070421114621-ee-5995875.wav
9 20070408122110-gd-.5995030.wav
names有日期,姓名和电话号码组成.
第一是实现按日期模糊查询就是我选择从一个日期到另一个日期查询如(20070101到20070501)
SELECT * FROM namelist WHERE left(names,7) BETWEEN '20070101 ' AND '20070401 '
第二是实现按姓名和电话号码模糊查询
select * from namelist where names like '%gd% ' or names like '%599% '
第一种按日期查询不行请大家帮帮忙有急
------解决方案--------------------表设计有问题,应该将日期、姓名与电话单独设计列
------解决方案--------------------SELECT * FROM namelist WHERE left(names,8) > '20070101 ' AND left(names,8) < '20070401 '
------解决方案-----------------------你应该去前8个---
SELECT *
FROM namelist
WHERE left(names,8) BETWEEN '20070101 ' AND '20070401 '
------解决方案--------------------SELECT * FROM namelist WHERE left(names,8) BETWEEN '20070401 ' AND '20070431 '