0

以下查询引发错误:

SELECT * FROM proposal_data
  INNER JOIN proposal_data
      ON proposal_data_second.proposal_id = proposal_data.proposal_id

  INNER JOIN proposal_data_second   
      ON proposal_data_third.proposal_id =  proposal_data_second.proposal_id
  INNER JOIN proposal_data_third
      ON proposal_data_fourth.proposal_id = proposal_data_third.proposal_id

错误是:

#1066 - Not unique table/alias: 'proposal_data'

我究竟做错了什么?

4

1 回答 1

1

您错误地加入表格。

在您当前的查询中,您在声明它之前加入表:

例如取前三行

SELECT * FROM proposal_data
  INNER JOIN proposal_data
      ON proposal_data_second.proposal_id = proposal_data.proposal_id

在这里,您在声明表之前proposal_data加入。proposal_data_secondproposal_data_second

此外,您不需要peoposal_data两次使用表名:

SELECT * FROM proposal_data
  INNER JOIN proposal_data --This is invalid syntax

尝试这个:

SELECT * FROM proposal_data
   INNER JOIN proposal_data_second
           ON proposal_data_second.proposal_id = proposal_data.proposal_id
   INNER JOIN proposal_data_third
           ON proposal_data_third.proposal_id = proposal_data_second.proposal_id
   INNER JOIN proposal_data_fourth
           ON proposal_data_fourth.proposal_id = proposal_data_third.proposal_id

有关更多信息,请参阅MySQL:JOIN语法

于 2013-04-27T07:03:46.133 回答