0

SQL クエリを使用してビューを作成しました。

CREATE VIEW rightview
AS 
SELECT data.accounts.login,data.accounts.password,data.customers.right_
FROM data.accounts join data.customers using (id);

クエリの実行をクリックすると、ビューが正常に作成されたことが示されます。しかし、このクエリでその列を表示しようとすると

select * from data.rightview;

このエラーが発生しました:

エラー コード 1356、SQL 状態 HY000: ビュー 'data.rightview' が無効なテーブル、列、関数を参照しているか、ビューの定義者/呼び出し元にそれらを使用する権限がありません

4

4 に答える 4

0

私見の方が良いでしょう:

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

テーブル customers がテーブル accounts への参照である列 ID を含む場合...

于 2013-11-04T10:30:12.890 に答える
0

これを試してみてください..

CREATE VIEW rightview
AS SELECT a.login,a.password,b.right_
FROM accounts a INNER JOIN customers b
on a.id = b.id;

それから、

select * from rightview;

動作します..

于 2013-11-04T11:57:24.973 に答える
0

テーブルエイリアスを使用してみてください

CREATE VIEW rightview
AS 
SELECT account.login,account.password,customer.right_
FROM data.accounts as account join data.customers as customer using (id);

select * from rightview;
于 2013-11-04T10:13:46.287 に答える