0

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

Flimzy
  • 68,325
  • 15
  • 126
  • 165
Raam Krish
  • 31
  • 1
  • 4

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
  • 42,799
  • 6
  • 22
  • 44
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,180
  • 20
  • 16
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
  • 659
  • 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
  • 143
  • 8