注册 登录
编程论坛 SQL Server论坛

多条件查询语句的问题

hao_t2010 发布于 2010-07-07 14:19, 797 次点击
有一个表,就两个字段,一个offerName,一个offerTel.
select offerName,offerTel from offer where offerName like '% aaa %' or offerTel like '% 138 %'
这是我写的语句,我想用户只输入名称可是查到,只输入电话也可以查到,两个同时输入就可以查到相对应的信息,可我这么写为什么只显示出电话开头为138的呢
4 回复
#2
qtsoft2010-07-07 14:41
你看看是不是模糊查询'% aaa %'和 '% 138 %'字符前后多了空格
#3
hao_t20102010-07-07 14:47
不是这个原因
#4
aei1352010-07-08 08:49
select offerName,offerTel from offer where offerName like '%aaa%' and  offerTel like '%138%'
1