最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PostgreSQL FULL JOIN 多表联合查询
时间:2011-05-22 编辑:简简单单 来源:一聚教程网
只要其中某个表存在匹配,FULL JOIN 关键字就会返回行。
FULL JOIN 关键字语法
SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
注释:在某些数据库教程中, FULL JOIN 称为 FULL OUTER JOIN。
postgres=#
postgres=# CREATE TABLE t1 (
postgres(# num int,
postgres(# name varchar(10)
postgres(# );
CREATE TABLE
postgres=#
postgres=# insert into t1 values(1,'a');
INSERT 0 1
postgres=# insert into t1 values(2,'b');
INSERT 0 1
postgres=# insert into t1 values(3,'c');
INSERT 0 1
postgres=#
postgres=# CREATE TABLE t2 (
postgres(# num int,
postgres(# name varchar(10)
postgres(# );
CREATE TABLE
postgres=#
postgres=# insert into t2 values(1,'xxx');
INSERT 0 1
postgres=# insert into t2 values(3,'yyy');
INSERT 0 1
postgres=# insert into t2 values(5,'zzz');
INSERT 0 1
postgres=#
postgres=# SELECT * FROM t1 FULL JOIN t2 ON t1.num = t2.num;
num | name | num | name
-----+------+-----+------
1 | a | 1 | xxx
2 | b | |
3 | c | 3 | yyy
| | 5 | zzz
-
上一个: sql千万级数据分页效率分析与方法
-
下一个: sql模糊查询语句详解
相关文章
- sql 多表联合查询 09-06
- sql 子查询、多表查询、联合查询方法 06-03
- MySQL登录、访问及退出操作解析 10-18
- sql语句 update字段null不能用is null问题解析 09-28
- SQL Server ISNULL 不生效原因及解决分析 09-28
- 关于if exists的用法及说明分析 09-28