1

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

  • inv_projID = 5
  • t2.is_msgID = t1.inv_ID and
  • t1.inv_memID = 1

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?

1 Answer 1

1

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.
Sign up to request clarification or add additional context in comments.

1 Comment

Dah... I guess writing code and watching live stream from businessofsoftware.org sort of dilutes ones attention...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.