Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to query out the first 20 results if category='art' and there is no value in image field.
category='art'
image
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
...AND Image IS NULL ORDER BY...
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)
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
...AND Image IS NULL ORDER BY...instead. Your questions asks for "no value" but your query is filtering for "image is NOT empty"; which do you need?