3 回答

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
只需將空值放入缺失的列中并使用UNION ALL
select name, surname, age, gender, height, null, null from table1
union all
select name, surname, age, gender, null, dateofbirth, origin from table2
正如@TheImpaler 所提到的,沒(méi)有辦法手動(dòng)選擇列。

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
請(qǐng)?jiān)囋囘@個(gè)。
SELECT
Name, Surname, Age, Gender, Height,NULL AS DateOfBirth,NULL AS Origin
FROM
table1
UNION ALL
SELECT
Name, Surname, Age, Gender, NULL AS Height, DateOfBirth, Origin
FROM
table2

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊
您可以使用 ROW_NUMBER 函數(shù)
SELECT t1.Column1, t1.Column2, t2.Column3, t2.Column4
FROM (
SELECT Column1, Column2,
ROW_NUMBER() OVER (ORDER BY Column1) AS rn
FROM Table1) AS t1
FULL OUTER JOIN (
SELECT Column3, Column4,
ROW_NUMBER() OVER (ORDER BY Column3) AS rn
FROM Table2) AS t2
ON t1.rn = t2.rn
- 3 回答
- 0 關(guān)注
- 118 瀏覽
添加回答
舉報(bào)