如何在mysql中加入2个视图?

时间:2017-09-13 21:13:12

标签: mysql views outer-join

我有两个列的视图,

view1 = (ID, Number)
view2 = (ID, Number, Name)

如何创建选择显示

Display = (ID, Number, Name)

和Display是FULL OUTER JOIN view1和view2。

1 个答案:

答案 0 :(得分:1)

SELECT view2.*
FROM   view1
       LEFT JOIN view 2
           ON view1.id = view2.id
UNION

SELECT view2.*
FROM   view1
       RIGHT JOIN view 2
           ON view1.id = view2.id