Not equal <> != operator on NULL

后端 未结 11 1550
南旧
南旧 2020-11-22 02:50

Could someone please explain the following behavior in SQL?

SELECT * FROM MyTable WHERE MyColumn != NULL (0 Results)
SELECT * FROM MyTable WHERE MyColumn <         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 03:27

    In SQL, anything you evaluate / compute with NULL results into UNKNOWN

    This is why SELECT * FROM MyTable WHERE MyColumn != NULL or SELECT * FROM MyTable WHERE MyColumn <> NULL gives you 0 results.

    To provide a check for NULL values, isNull function is provided.

    Moreover, you can use the IS operator as you used in the third query.

    Hope this helps.

提交回复
热议问题