Srinivasan
Srinivasan

Reputation: 12040

Oracle NULL value also filtering

Im trying to filter the category 'Student'. But NULL category also filtering out. Could you please let me know how to filter only Student not NULL value.

Query:

select * from customer where category != 'Student'

Upvotes: 0

Views: 57

Answers (1)

Alex Poole
Alex Poole

Reputation: 191275

Null isn't comporable with anything, even itself. To include it you need to have a separate condition for it:

select * from customer where category is null or category != 'Student'

You could also nvl or coalesce the column to a magic value, but explicitly looking for null is cleaner, I find.

Quick SQL Fiddle.

Upvotes: 1

Related Questions