[英]Joins are erroring with multiple tables
我正在嘗試將多個表連接在一起,只獲得一些字段
這是我的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
JOIN umtc_class AS t2
on t1.match_id = t2.match_id
'在第2行
我一直在弄亂它,但是我什么也沒辦法。...任何想法都說明為什么它不起作用?
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 --<-- This ON clause should have t4 in it
JOIN location AS t5
on t3.location_id = t3.location_id --<-- This ON clause should have t5 in it
JOIN location AS t6
on t5.city_id = t6.city_id
任何ON
子句都應定義表名或表聯接中已跟隨的表名與先前的結果集之間的關系。
MATCH是函數名稱,因此是保留字。 嘗試使用標准名稱的表名和數據庫名稱作為前綴:
SELECT ...
FROM mydb.match AS t1
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 = t4.provider_id //here was mistake
JOIN location AS t5
on t3.location_id = t5.location_id //here was mistake
JOIN location AS t6
on t5.city_id = t6.city_id
而不是使用match嘗試使用[match],即在[和]之間包含匹配
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.