Why won't this SQL statement work?
oracle, sql
Solution
SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%';
1) Oracle treats '' as NULL, which means the comparison "NOT name = ''" is never true or false; use "IS NOT NULL" instead. But...
2) The second condition "name LIKE '%.EDIT%' will not match an empty string anyway, making the first condition redundant.
So re-write as:
SELECT DISTINCT name FROM log WHERE name LIKE '%.EDIT%';
Problem
I have the following SQL-statement: ``` SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%'; ``` It works fine on Postgres (returns all different names from log, which aren't empty and contain the string '.EDIT'). But on Oracle this statement doesn't work. Any idea why?