我試圖聯合多個表,只得到一些字段的示數加入多個表
這裏是我的SQL代碼:
SELECT t1.match_id, t1.provider_id, t1.visible, t2.match_type, t3.class_num, t3.location_id, t4.prov_name, t6.city_name
FROM match AS t1
JOIN umtc_class AS t2
on t1.match_id = t2.match_id
JOIN abroad_class AS t3
on t1.match_id = t3.match_id
JOIN provider AS t4
on t1.provider_id = t3.provider_id
JOIN location AS t5
on t3.location_id = t3.location_id
JOIN location AS t6
on t5.city_id = t6.city_id
1064 - 你在你的SQL有一個錯誤句法;檢查對應於你的MySQL服務器版本在第2行
我一直用它瞎搞使用近「比賽爲T1
JOIN umtc_class AS t2
on t1.match_id = t2.match_id
」正確的語法手冊,但我不能讓任何地方。 ...有什麼想法,爲什麼它不工作?
可能不是你的語法錯誤,但你可能並不想這樣做(下面T5加入):上t3.location_id = t3.location_id – BryPie
另外,你的意思是加入位置表兩次? – BryPie
它往往更容易發現問題,這樣,如果你的表的別名有有意義的名字,而不是T1,T2,T3等 – Siyual