我使用 SQL 查询创建了一个 View :
CREATE VIEW rightview
AS
SELECT data.accounts.login,data.accounts.password,data.customers.right_
FROM data.accounts join data.customers using (id);
当我点击执行查询时,表明 View 已成功创建。但是当我尝试使用此查询显示其列时
select * from data.rightview;
我收到此错误:
Error code 1356, SQL state HY000: View 'data.rightview' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
最佳答案
恕我直言,更好的是:
CREATE VIEW rightview
AS
SELECT acc.login, acc.password, cust.right_
FROM data.accounts acc
LEFT JOIN data.customers cust on acc.id=cust.id
如果表客户包含引用表帐户的列 ID...
关于mysql - 显示 View sql 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19765474/