Reputation: 3285
I have the following query:
SELECT box, name from box where 'name' != ''
but it doesn't seem to take into account the where condition into account and execute the entire query as if that condition was not there.
I essentially want to only retrieve data where there is information found in the name column.
Any help would be appreciated
Upvotes: 0
Views: 40
Reputation: 14341
SELECT box, name from box where 'name' != ''
'name'
is a string so the string 'name'
is NOT EQUAL
to the string ''
which is always true.
SELECT box, name from box where name != ''
If you want where a string is not null and not empty string then you could do something like this:
SELECT box, name from box where COALESCE(name,'') != ''
and to take into account whitespace
SELECT box, name from box where COALESCE(TRIM(name)),'') != ''
Upvotes: 2