[英]Joins are erroring with multiple tables
I'm trying to join multiple tables together and only get some of the fields 我正在尝试将多个表连接在一起,只获得一些字段
here's my sql code: 这是我的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
' at line 2 '在第2行
I keep messing around with it but I can't get anywhere....any ideas has to why it isn't working? 我一直在弄乱它,但是我什么也没办法。...任何想法都说明为什么它不起作用?
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
Any ON
clause should define the relation between the table name is has followed and preceding result set from a table or joins of tables. 任何
ON
子句都应定义表名或表联接中已跟随的表名与先前的结果集之间的关系。
MATCH is a function name and thus a reserved word. MATCH是函数名称,因此是保留字。 Try using the fully qualified table name with the database name prepended:
尝试使用标准名称的表名和数据库名称作为前缀:
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.