My query is not giving proper results when I try to select user records that don’t have email:
select * from users where email=''
And:
select * from users where email=NULL
Both give different results but neither give correct results. How can I get correct results?
It’s IS NULL or IS NOT NULL.
Depending on HOW a user can have ‘no e-mail’, you should set the default value of the field to NULL and make the field nullable. Then if an insert is performed of a new record in that table, the e-mail will be NULL rather than empty.
Alternatively if you’re already stuck with a mismatched table, try something like:
That’ll give you all records with an ’empty’ value for
email, treating NULL as empty.