0

我有两张桌子EmployeeCustomer.

我想要一个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。请帮忙!

4

1 回答 1

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;
于 2013-05-07T00:26:57.767 回答