我有这个问题;
SELECT * FROM (`products`) WHERE `show_in_store` = 1 AND
`category` = '8' AND `stock` >= 0 AND `name` LIKE '%a%'
OR `description` LIKE '%a%' ORDER BY `product_id` asc
它应该只返回一些结果(类别设置为8的结果),但它返回所有内容,包括具有不同类别的结果......
LIKE函数是否写了AND语句,还是排序问题?
答案 0 :(得分:1)
尝试
SELECT * FROM `products`
WHERE
`show_in_store` = 1
AND `category` = '8'
AND `stock` >= 0
AND ( `name` LIKE '%a%' OR `description` LIKE '%a%')
ORDER BY `product_id` asc