oracle - Check for != values when column contains records with NULLs -
i have number of tables mix 'real' values nulls in columns. exerience, issuing select against these looks like:
select column1, column2, column3 mytable column1 != 'a value';
...doesn't return records expect. in current table working on, returns empty recordset, though know have records in table nulls in column1, , other records in table have value "!="ing in column1. expecting, in case, see records nulls in column1 (and, of course, else if there other not 'a value' values in column1.
experimenting nvl in clause doesn't seem give me different:
select column1, column2, column3 mytable nvl(column1, '') != 'a value';
...is returning empty recordset.
using 'is null' technically give me correct recordset in current example, of course if records change 'another value' in column1, null exclude those.
null can't compared in same way other values can be. must use null. if want include null values, add or clause:
select column1, column2, column3 mytable column1 != 'a value' or column1 null
Comments
Post a Comment