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)
加载中,请稍侯......
精彩评论