只要两张表字段类型、数目一致,可用以下方法连接成一张表:
1.左连接 left join 或 left outer join;
2.右连接 right join 或 right outer join;
3.完全外连接 full join 或 full outer join;
4.内连接 join 或 inner join。
例如:表A(a,b)和表B(e,f)两个毫无关联的表
SELECT
A1.a ,
A1.b ,
B1.e ,
B1.f
FROM
(
SELECT
ROW_NUMBER() OVER (
ORDER
BY
a ) id ,
a ,
b
FROM
A
) A1
FULL
JOIN
(
SELECT
ROW_NUMBER() OVER (
ORDER
BY
e ) id ,
e ,
f
FROM
B
) B1
ON
A1.id = B1.id