santa
santa

Reputation: 12512

mySQL query help needed

I have two tables:

t1
------------------
inv_ID
inv_memID
inv_projID

t2
------------------
is_ID
is_msgID
is_contID

I need to get all t2.is_contID into an array where

Seem pretty straight forward but I'm stuck... Tried this:

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 

What am I missing?

Upvotes: 1

Views: 29

Answers (1)

Johan
Johan

Reputation: 76537

FROM comes before 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 is very fussy about the order of the keywords.
The correct order is:

SELECT
FROM
JOIN
WHERE
HAVING
GROUP BY
ORDER
LIMIT    <<-- MySQL only, other DB's user other keywords in other places.

Upvotes: 1

Related Questions