我有两张表Employee
和Customer
。
我想要Employee
的名称和地址,然后在一个视图中找到Customer
的名称和地址。
这就是我所拥有的:
CREATE VIEW Mail_List AS
SELECT C.CustName, C.CustAddress
FROM Customers C
UNION
Select E.EmpCustName, E.EmpCustAddress
From Employees E;
但它说No rows were affected
。请帮忙!
答案 0 :(得分:1)
No rows were affected
不是SELECT
操作应出现的错误。
你是怎么称呼这个观点的?试着这样做:
SELECT * FROM Mail_List;
为清楚起见,您可以将视图重写为:
CREATE OR REPLACE VIEW Mail_List AS
SELECT C.CustName AS name, C.CustAddress AS address, 'customer' AS `type`
FROM Customers C
UNION ALL
SELECT E.EmpCustName AS name, E.EmpCustAddress AS address, 'employee' AS `type`
From Employees E
ORDER BY name;