0

I have 2 different queries (with different purposes) working perfectly but there is something I can not grasp yet about the Null value

Here is one query:

 select NCLI , LOCALITE , CAT 
 from CLIENT
 where CAT not in (’B1’,’C1’)
 or LOCALITE not in (’Lille’,’Namur’);

It shows exactly what I want Including the rows where CAT has a null value. Now this seems perfectly logical to me.

The only thing that disturbs me is that the query below only worked when I specified I did wanted the null rows in CAT to show up

select NCLI , LOCALITE , CAT from CLIENT
where CAT <> ’C1’
or CAT is null
or LOCALITE = ’Namur’;

When I don't add -- or CAT is null -- the null values don't show up. Could someone tell me what I'm not grasping here yet? Thanks.

KastelA Kastel
  • 83
  • 1
  • 1
  • 3
  • 1
    All comparisons return `NULL` -- which is treated as false -- when one or both arguments are `NULL`. Except for `IS NULL`. – Gordon Linoff Nov 30 '14 at 14:00
  • So many duplicates, but I think I like [the answer here](http://stackoverflow.com/questions/9581745/sql-is-null-and-null) best. – Clockwork-Muse Nov 30 '14 at 15:07

0 Answers0