0

i have this simple SQL join query, which is giving me a syntax error on the second FROM

SELECT * FROM ##temporderstable P 
FROM supporder Y join backorder ON P.catalogid = Y.backorder 
GROUP BY P.catalogid

i can't figure out whats wrong with it, any hints?

Thanks in advance

1
  • 1
    You need to change the second from clause to a join Commented Oct 18, 2012 at 3:11

4 Answers 4

3

You can't have two FROM clauses like that...

You might mean JOIN but you'd need another ON condition:

SELECT *
  FROM ##temporderstable P 
  JOIN supporder Y ON P.catalogid = Y.backorder 
  JOIN backorder B ON B.xxxxxxxxx = P.xxxxyyyyy
 GROUP BY P.catalogid;

The second ON would need to reference a column of B and a column of either P or Y.

Sign up to request clarification or add additional context in comments.

Comments

3
SELECT * 
FROM 
    ##temporderstable P 
    JOIN supporder Y 
    ON P.catalogid = Y.backorder 
GROUP BY P.catalogid

Also, your query doesn't have any aggregate functions, so you should think of the need for GROUPing on P.catalogid

Comments

1

Your query has two FROM clause. It should be something like this.

SELECT 
    * 
FROM 
    ##temporderstable P 
INNER JOIN 
    supporder Y 
ON 
    P.catalogid = Y.backorder 
GROUP BY 
    P.catalogid

Comments

1

Two From clause is not applicable. You have to use only one and inside that you have to join two tables.

Comments

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.