我有三個表我試圖從中選擇數據,每個表都有一個pID,這就是我想要的連接所基於的。當我運行以下查詢時,我仍然以三個pID字段結束。在mysql中選擇連接多個表?
我的select連接語句出了什麼問題?
SELECT * FROM Player p
LEFT JOIN AvgStats a ON a.pID = p.pID
LEFT JOIN MisTotal m ON m.pID = p.pID;
Player Table
pID | Name | Age
AvgStats Table
pID | 3pt% | gamePoints
MisTotal Table
pID | Fouls | rebounds
我想創造一個返回
pID | Name | Age | 3pt% | gamePoints | Fouls | rebounds
不要使用'select *',列出你想返回的列。 – Taryn
我想選擇所有的列,會做所有的項目比*快嗎? – LF4
如果您選擇*,那麼您將得到三個名爲'pId'的列。通過實際命名列,您將只返回所需的列而不重複。你應該命名列,'選擇p.pid,p.name,p.age,a.3pt%等' – Taryn