日期:2014-05-17  浏览次数:20466 次

关于SQL模糊查询
假设一个表里有个字段内容是这样的"c104,c111,c135,c67" 也就是说这个字段的内容在提交的时候可以是多项的,比如"r23"或者"t15,t45,t38````"

我要查找"c104",或者"r23",我的语句是:
CString strSQL,location;
m_location.GetWindowText(location);
strSQL.Format("select * from userinfo where Rev_ds like "%s" ",location);

不知什么原因,我的框框无论输入"c104"还是"r23"还是"t15",都得不到结果,就是无值.
请大师指教,这个问题应该怎么弄

------解决方案--------------------
调试出strSQL的值
------解决方案--------------------
strSQL.Format("select * from userinfo where Rev_ds like '%%%s%%' ",location);
------解决方案--------------------
要2个%的吧  LIKE  '%s%'  

只有1个% 只是模糊查询 头或者尾
------解决方案--------------------
 Rev_ds like '%s'   不是匹配在Rev_ds字段中 以s结尾的的字符串吗?