爲什麼在MySQL中查詢錯誤(1060) Duplicate column name 'studentID'
?我怎樣才能防止它?#1060 - 重複列名稱
CREATE TEMPORARY TABLE tempTable
select * from member_infos
join contact_infos on member_infos.studentID=contact_infos.studentID
爲什麼在MySQL中查詢錯誤(1060) Duplicate column name 'studentID'
?我怎樣才能防止它?#1060 - 重複列名稱
CREATE TEMPORARY TABLE tempTable
select * from member_infos
join contact_infos on member_infos.studentID=contact_infos.studentID
如果你使用MySQL的USING
條款(替代ON
),它只會產品用於湊SELECT
結果這些表共享領域的一個副本。
如果還有其他字段共享名稱,USING
不能幫到你;您需要明確列出所有字段,以便排除(或別名)具有相同名稱的字段。
USING
涵蓋在MySQL JOIN documention中。
您的JOIN結果包含2列同名studentID
。從這個結果你想創建一個表。但是表格需要唯一的列名稱。
所以最好不要使用select * from ...
,而是要命名每一列。
不使用select *指定列名 –