返回两个结果的交集

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

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