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

How to join 2 views in mysql?

本问题已经有最佳答案,请猛点这里访问。

我有两个带列的视图,

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

如何创建选择显示,以便

1
Display = (ID, Number, Name)

显示为完整的外部连接视图1和视图2。


1
2
3
4
5
6
7
8
9
10
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