sql - Why does a string match NULL in SQLite? -


i have 2 tables:

create table foo(     id      varchar,     data    varchar );  create table bar(     id      varchar,     foo_id  varchar );

when run query: select * foo id='eb7ab72d7802d1146b72e3f1d761bfa2382be102' , id not in (select foo_id bar) no results.

however, if change query select * foo id='eb7ab72d7802d1146b72e3f1d761bfa2382be102' , id not in (select foo_id bar foo_id not null) correct result.

the data in tables similar follows:

 foo:  10af193a2c0465b6dad69c4e9e2bf86321961434, blah 10af193a2c0465b6dad69c4e9e2bf86321961434, bloo ed724bb8f46596a8f14b891de4b6be5adb0b5903, fdsj ed724bb8f46596a8f14b891de4b6be5adb0b5903, fdsjio eb7ab72d7802d1146b72e3f1d761bfa2382be102, baz  bar:  0009546da32efb77cb29f21e7399a8242866bbc1, 10af193a2c0465b6dad69c4e9e2bf86321961434 b732ea74329257213d7076f7672ccd8b1df8e41b, (null) 7a6752afad1f7a887127a38937c15729673ef25f, ed724bb8f46596a8f14b891de4b6be5adb0b5903  

comparisons null cannot made. in first query boolean result of statement 'unknown' instead of true or false.

check out blog post nicely detailed explanation:
http://www.sqlbadpractices.com/using-not-in-operator-with-null-values/


Comments

Post a Comment

Popular posts from this blog

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -