NULL values in where clause

后端 未结 6 738
花落未央
花落未央 2020-12-11 02:17

i\'ve got a table \"bla\" like this:

[id]    [name]    [fk]
1       test      4
2       foo       5
3       bar       NULL

if i do the sql

6条回答
  •  离开以前
    2020-12-11 03:08

    NULL is not a value, but rather the unknown absence of a value. If you'd like to test for NULL, you have to do so explicitly by using IS NULL and IS NOT NULL. For example, NULL will test FALSE even against NULL itself. So, working with NULL is only done with the aforementioned functions (and ISNULL()). Your query could be rewritten as

    SELECT * FROM bla WHERE fk <> 4 OR fk IS NULL
    

提交回复
热议问题