[英]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.