多表关联
最近更新时间: 2025-02-18 16:02:00
- 内连接。
postgres=# select * from tbase inner join t_appoint_col on tbase.id=t_appoint_col.id;
id | nickname | id | nickname
----+-----------------------------+----+-------------
1 | hello TDSQL PG | 1 | hello TDSQL PG
1 | TDSQL PG分布式数据库的时代来了 | 1 | hello TDSQL PG
(2 rows)
- 左外连接。
postgres=# select * from tbase left join t_appoint_col on tbase.id=t_appoint_col.id;
id | nickname | id | nickname
----+-----------------------------+----+-------------
1 | hello TDSQL PG | 1 | hello TDSQL PG
2 | TDSQL PG好 | |
1 | TDSQL PG分布式数据库的时代来了 | 1 | hello TDSQL PG
(3 rows)
- 右外连接。
postgres=# select * from tbase right join t_appoint_col on tbase.id=t_appoint_col.id;
id | nickname | id | nickname
----+-----------------------------+----+-------------
1 | TDSQL PG分布式数据库的时代来了 | 1 | hello TDSQL PG
1 | hello TDSQL PG | 1 | hello TDSQL PG
| | 5 | Power TDSQL PG
(3 rows)
- 全连接。
postgres=# select * from tbase full join t_appoint_col on tbase.id=t_appoint_col.id;
id | nickname | id | nickname
----+-----------------------------+----+-------------
1 | hello TDSQL PG | 1 | hello TDSQL PG
2 | TDSQL PG好 | |
1 | TDSQL PG分布式数据库的时代来了 | 1 | hello TDSQL PG
| | 5 | Power TDSQL PG
(4 rows)