In a database, among the fields, I have two fields which are picName and UserName.
The picName can have a NULL value, a picture's name or it can be empty.
I want to query the userName of those entries whose picName is either NULL or empty.
I tried these commands separately
Select userName from user where picName = ''
Select userName from user where picName IS NULL
But I want to get both the results in 1 query.
I tried using IN operator like this
Select userName from user where picName IN ('' , IS NULL)
But it didn't work.
How should I do it...?
use OR if you have multiple filters in your condition
Select userName 
from user 
where picName IS NULL OR 
      picName = ''
                        An alternative to the other answers is to use MySQL's IFNULL() or COALESCE() functions:
SELECT userName FROM user WHERE IFNULL(picName='',TRUE);
SELECT userName FROM user WHERE COALESCE(picName,'') = '';
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With