1

sqlite3 では、次の構文を使用してテーブルに行を挿入しました。

INSERT INTO schedule VALUES(some_date, (SELECT id_from_another_table WHERE where_clause));

明らかな仮定のように思われるのは、この埋め込み (SELECT ...) クエリは、結果セットが空の場合に NULL を返すということです。

しかし、そうではないようです...

sqlite> .schema schedule
CREATE TABLE schedule(date date, agent_id integer);

sqlite> select * from schedule;
2014-01-09|22
2014-01-09|
2014-01-09|23
2014-01-09|24

2 行目に agent_id のエントリがないことに注意してください。

sqlite> select * from schedule where agent_id = null;
#nothing

sqlite> select * from schedule where agent_id = 0;
#nothing

sqlite> select * from schedule where agent_id = "";
#nothing

sqlite> select * from schedule where agent_id LIKE "% %";
#nothing

そのagent_idがnull、""、0、またはスペースを含むものと一致しない場合、それは一体何ですか?

前もって感謝します!:-)

4

1 に答える 1

2

私が使用した他のすべてのDBでは、構文はcolumn IS NULL. 私が見ることができるものから、それはsqliteでも同じです。

select * from schedule where agent_id IS NULL;
于 2014-01-05T21:53:16.873 に答える