I'm trying to write a query that simply selects all non-empty names. Both the following queries return no results:
SELECT name FROM MyTable WHERE name != '';
SELECT name FROM MyTable WHERE name = '';
For context, both of these queries do return results:
SELECT name FROM MyTable WHERE name != 'a';
SELECT name FROM MyTable WHERE name IS NOT NULL;
I read somewhere that the empty string is equivalent to NULL in oracle, but I still don't see why that explains this behaviour. I need to support both SQL Server and Oracle which is why I can't just rely on WHERE name IS NOT NULL
Can anyone explain what's happening here? Thanks!