Tips & Tricks – Sybase T-SQL: <> does not match null values

When writing SQL we may find that we need to write a WHERE clause that checks if a columns is not a certain value. To do this we have the <> operator that means does not equal. However you may be surprised that you are not getting all the results you expected, this is because <> does not match null values. To get all values that are not equal you need to check that a value is not equal or that it is null.

Examples SQL

select * from CLIENT
where SENSITIVE <> 'Y' or SENSITIVE is null
// T-SQL // Tips & Tricks //

Comments & Questions

Add Your Comment