下面的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
关于mysql - 使用MySQL进行IN后内部联接两个表上的SQL语法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34075175/