Why is this SQL statement not working?

I have the following SQL statement:

SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%';

It works fine in Postgres (returns all log names that are not empty and contain the string ".EDIT"). But in Oracle, this statement does not work. Any idea why?

+5
source share
3 answers
SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%';

1) Oracle treats "as NULL", which means that the comparison "NOT name =" "is never true or false; use" NOT NULL "instead. But ...

2) The second condition "name LIKE"% .EDIT% 'will still not be equal to an empty string, which makes the first condition redundant.

So rewrite as:

SELECT DISTINCT name FROM log WHERE name LIKE '%.EDIT%';
+16
source

Oracle NULL, . NAME NOT NULL

+3

"NOT NAME=".

 SELECT DISTINCT name 
 FROM log
 WHERE name LIKE '%.EDIT%';

?

If not, how does this not work? Does this cause an error? Have the wrong results returned?

Please expand your question with this information :-)

+2
source

All Articles