简单关键字查询的SQL语句?
SELECT TOP "+num+ " id,name,width,height,path,fileSize FROM xxxtable WHERE (ID NOT IN(SELECT TOP "+rag+ " id FROM xxxtable ORDER BY id)) ORDER BY ID
这个语句是从rag中查找num条记录
现在变一下
从rag中查找num条字段name是 "car "的记录,多了个where like '%car% '
这个where 写在那里呢?
------解决方案--------------------SELECT TOP "+num+ " id,name,width,height,path,fileSize FROM xxxtable WHERE (ID NOT IN(SELECT TOP "+rag+ " id FROM xxxtable ORDER BY id)) and car like '%car% ' ORDER BY ID
------解决方案--------------------SELECT TOP "+num+ " id,name,width,height,path,fileSize FROM xxxtable WHERE (ID NOT IN(SELECT TOP "+rag+ " id FROM xxxtable ORDER BY id)) and name like '%car% ' ORDER BY ID
------解决方案--------------------上面的sql写错了,里面的查询条件也要加上name like '%car% '
SELECT TOP "+num+ " id,name,width,height,path,fileSize FROM xxxtable WHERE (ID NOT IN(SELECT TOP "+rag+ " id FROM xxxtable where name like '%car% ' ORDER BY id)) and name like '%car% ' ORDER BY ID