0

I get different outputs for these queries. Did anyone face this?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Raam Krish
  • 31
  • 1
  • 5

4 Answers4

2

The col= null would not work because

NULL means I don't know. which is a placeholder to say there is the absence of a value.

= evaluate for values, so that will not to work.

You need to use IS NULL to get NULL row value.

D-Shih
  • 44,943
  • 6
  • 31
  • 51
0

That's completely normal. "X = NULL" is NULL, which amounts to false ("NOT X = NULL" is also false; NULL is falser than false). For most SQL dialects.

Mischa
  • 2,240
  • 20
  • 18
0

=NULL IS is an expression of a value and IS NULL is the preferred method of evaluating the condition of a variable being NULL.

Here is the detail description Click here

Saurabh Ghewari
  • 689
  • 3
  • 8
0

The first statement, SELECT * FROM bookings where code = null--

It Checks Directly if any row has the value null

The Second Statement, SELECT * FROM bookings where code IS null

It Checks all the rows its a null or not..

Ranjith
  • 153
  • 8