[英]SQL syntax on inner join two table after IN using MySQL
我在以下sql查询中遇到问题
SELECT c.item1 ,c.id, a.id
FROM table_c as c
WHERE c.id IN
(
SELECT id
FROM table_b
WHERE someinfo = 'active'
)
AND c.id IS NOT NULL
INNER JOIN table_a as a
ON c.id=a.id
问题出在INNER JOIN
INNER JOIN table_a as a
ON c.id=a.id
Sequel Pro输出
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN
有人可以给我一些见解吗
未经测试:内部联接应该在WHERE子句之前
SELECT c.item1 ,c.id, a.id
FROM table_c as c
INNER JOIN table_a as a ON c.id=a.id
WHERE c.id IN
(
SELECT id
FROM table_b
WHERE someinfo = 'active'
)
AND c.id IS NOT NULL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.