多表关联
 
                  更新时间 2025-02-05 09:36:29
                 
 
                    最近更新时间: 2025-02-05 09:36:29
                  
 本文为您介绍SELECT语法中多表关联的使用方法。
 内连接
teledb=# select * from teledb_pg inner join teledb_pg1 on teledb_pg.id = teledb_pg1.id;
 id | nickname | id | nickname 
----+----------+----+----------
  3 | pg       |  3 | pg
(1 row)
左外连接
teledb=# select * from teledb_pg left join teledb_pg1 on teledb_pg.id = teledb_pg1.id;
 id |  nickname  | id | nickname 
----+------------+----+----------
  1 | teledb    |    | 
  1 | hello,pgxc |    | 
  2 | TELEDB    |    | 
  3 | pg         |  3 | pg
  4 |            |    | 
(5 rows)
右外连接
teledb=# select * from teledb_pg right join teledb_pg1 on teledb_pg.id = teledb_pg1.id;
 id | nickname | id | nickname 
----+----------+----+----------
    |          |  5 | test
  3 | pg       |  3 | pg
(2 rows)
全连接
teledb=# select * from teledb_pg full join teledb_pg1 on teledb_pg.id = teledb_pg1.id;
 id |  nickname  | id | nickname 
----+------------+----+----------
  1 | teledb    |    | 
  3 | pg         |  3 | pg
  4 |            |    | 
  1 | hello,pgxc |    | 
  2 | TELEDB    |    | 
    |            |  5 | test
(6 rows)
