SQL - 将两个表合并为一个

时间:2013-11-18 09:06:40

标签: mysql

我有两张桌子自行车和车。

自行车桌

bikeID | name |desc

车牌

carID | name | desc.

我需要将两个表合并为一个这样的

bikeID | carID | name | desc

1 个答案:

答案 0 :(得分:0)

如果我说得对,请尝试使用UNION

SELECT * INTO NEW_TABLEN_NAME FROM
(
SELECT BikeId, NULL as CarID, name,desc FROM Bike
UNION ALL
SELECT NULL as BikeId, CarID, name,desc FROM Car
) T