Vincent Claes
Vincent Claes

Reputation: 4768

Query case sensitive in SQL database without setting database to case sensitive

I have a column IsSeeded with values 'N' and 'NULL' as one of the possibilities I want to select all records that don't have a 'N' in their field.

when I query

select * from database.file where IsSeeded !='N';

it also doesn't return the files with values 'NULL'. How can I allow 'NULL' values without having to change my databasepreferences to case sensitive?

Upvotes: 1

Views: 300

Answers (1)

juergen d
juergen d

Reputation: 204774

You have to use the IS operator when comparing to null values instead of the normal compare operators (!=/=/<>/...)

select * from database.file 
where IsSeeded IS NULL;

Otherwise the result will be unknown for null entries and the condition is false.

Upvotes: 1

Related Questions