开发者

mysql query if value is empty

I want to query out the first 20 results if category='art' and there is no value in image field.

Can I writ开发者_StackOverflow中文版e an SQL query like this?

SELECT image,date,category FROM imagecart WHERE category='art' AND image != '' Order By date DESC LIMIT 0,20


Alternatively:

SELECT image,date,category 
FROM imagecart 
WHERE category='art' 
AND LENGTH(image) = 0 
ORDER BY  date DESC LIMIT 0,20

Modify as you need to check for nulls:

AND (LENGTH(image) = 0 OR image IS NULL)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜