0

我对以下查询有疑问:

SELECT * FROM (
  (SELECT * FROM Images 
   WHERE create_user_id=:user_id) RIGHT INNER JOIN 
  (SELECT * FROM PhotoGallery) ON id=centity_id
 )
 ORDER BY centity_id;

我收到 1248 - 每个派生表都必须有自己的别名错误,我知道我需要为这些表提供别名,但无论我做什么,我总是会出错。谁能帮我解决这个问题?非常感谢!

4

4 回答 4

0

If you are doing a select *, you don't need to do a sub-query.

SELECT * FROM Images 
  RIGHT OUTER JOIN PhotoGallery ON id=centity_id
WHERE create_user_id = :user_id
ORDER BY centity_id;
于 2013-02-20T18:22:32.550 回答
0

尝试这个

SELECT * 
  FROM Images i RIGHT JOIN
       PhotoGallery p ON i.id=p.centity_id
 WHERE i.create_user_id=:user_id
 ORDER BY p.centity_id

根据您的 DDL 和您所需的输出连接可能是RIGHT,INNERLEFT, 但不是RIGHT INNER JOIN

于 2013-02-20T18:21:06.567 回答
0

您的子查询需要别名。就像是:

SELECT * FROM (
  (SELECT *
   FROM Images 
   WHERE create_user_id=:user_id
  ) i RIGHT INNER JOIN 
  PhotoGallery pg
  ON i.id=pg.centity_id
 )
 ORDER BY centity_id;
于 2013-02-20T18:21:15.530 回答
0

我从未听说过支持“RIGHT INNER JOIN”的 dbms。选择其中之一

  • 内连接,或
  • 右外连接,或
  • RIGHT JOIN(应该与 RIGHT OUTER JOIN 相同)。
于 2013-02-20T18:21:19.727 回答