我有两张桌子:
t1
------------------
inv_ID
inv_memID
inv_projID
t2
------------------
is_ID
is_msgID
is_contID
我需要将所有 t2.is_contID 放入数组
看起来非常直接,但我被卡住了......试过这个:
SELECT t2.is_contID
INNER JOIN t1 ON (t1.inv_ID = t2.is_msgID)
FROM t2
WHERE t1.inv_projID = 5
AND t1.inv_memID = 1
我错过了什么?
答案 0 :(得分:1)
FROM
出现在JOIN
之前。
SELECT t2.is_contID
FROM t2
INNER JOIN t1 ON (t1.inv_ID = t2.is_msgID)
WHERE t1.inv_projID = 5
AND t1.inv_memID = 1
SQL对关键字的顺序非常挑剔 正确的顺序是:
SELECT
FROM
JOIN
WHERE
HAVING
GROUP BY
ORDER
LIMIT <<-- MySQL only, other DB's user other keywords in other places.