IN Operator SQL

后端 未结 7 1541
庸人自扰
庸人自扰 2020-12-11 22:21

I have a table called NUMS with a single column n.
And I fill values 1,2,3,4,5,null in it.

Now a query

SELECT n FROM Nums 
 WHERE n IN (1, 2,         


        
7条回答
  •  伪装坚强ぢ
    2020-12-11 23:03

     SELECT n FROM Nums  
     WHERE n IN (1, 2)
      Or n Is null
    

    This will retrieve what you intend to get. As said by Mitch normally a comparison to Null yields UNKNOWN. This is because NULL itself is defined as an undefined value. It's like saying I lived in Nottingham, Birmingham and somewhere. Finding somewhere on the world map can prove a bit tricky as it is undefined.

提交回复
热议问题