返回两个结果的差集

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

  • 复制
    复制成功
postgres=# create table t_except1(id int,mc text);
CREATE TABLE
postgres=# insert into t_except1 values(1,'TDSQL PG'),(2,'TDSQL PG');
INSERT 0 2
postgres=# create table t_except2(id int,mc text);
CREATE TABLE
postgres=# insert into t_except2 values(1,'TDSQL PG'),(3,'TDSQL PG');
INSERT 0 2
postgres=# select * from t_except1 except select * from t_except2;
 id |  mc   
----+-------
  2 | TDSQL PG
(1 row)