如果category='art'
image
并且SELECT image,date,category FROM imagecart WHERE category='art' AND image != '' Order By date DESC LIMIT 0,20
字段中没有值,我想查询前20个结果。
我可以写这样的SQL查询吗?
{{1}}
答案 0 :(得分:6)
可替换地:
SELECT image,date,category
FROM imagecart
WHERE category='art'
AND LENGTH(image) = 0
ORDER BY date DESC LIMIT 0,20
修改,因为您需要检查空值:
AND (LENGTH(image) = 0 OR image IS NULL)