以下查询引发错误:
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'
我做错了什么?
答案 0 :(得分:1)
你错误地加入了表格。
在当前查询中,您在声明之前加入表格:
e.g。先前三行
SELECT * FROM proposal_data
INNER JOIN proposal_data
ON proposal_data_second.proposal_id = proposal_data.proposal_id
此处,您在宣布proposal_data
表格之前加入proposal_data_second
proposal_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
Syntax