not in中包含了null,结果全为真

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# create table t_not_in(id int,mc text);
CREATE TABLE
postgres=# insert into t_not_in values(1,'TDSQL PG'),(2,'pgxz');
INSERT 0 2
postgres=# select * from t_not_in where id not in (3,5);
 id |  mc   
----+-------
  1 | TDSQL PG
  2 | pgxz
(2 rows)

postgres=# select * from t_not_in where id not in (3,5,null);
 id | mc 
----+----
(0 rows)