Reputation: 9221
I want to query out the first 20 results if category='art'
and there is no value in image
field.
Can I write an SQL query like this?
SELECT image,date,category FROM imagecart WHERE category='art' AND image != '' Order By date DESC LIMIT 0,20
Upvotes: 1
Views: 3771
Reputation: 100567
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)
Upvotes: 6