我正在尝试在查询中使用JOIN而无法弄清楚为什么我会得到
SQL命令未正确结束
错误。这是我正在尝试运行的查询:
select
v.contid, v.group_id, a.user_id
from
application_users a, web_users v
where
a.is_active = 1
and v.group_id in (22, 26, 595, 635)
and a.user_id = v.user_id
join
contest_results cr on cr.user_id = a.user_id
where
cr.period = 201502
答案 0 :(得分:4)
这不是JOIN
多个表的正确语法。
也不要使用逗号分隔的连接始终使用更具可读性的INNER JOIN
语法。试试这个
SELECT v.contid,
v.group_id,
a.user_id
FROM application_users a
INNER JOIN web_users v
ON a.user_id = v.user_id
INNER JOIN contest_results cr
ON cr.user_id = a.user_id
WHERE cr.period = 201502
AND a.is_active = 1
AND v.group_id IN ( 22, 26, 595, 635 )