1

What's wrong with this code?

FROM product_tag, ps_product_tags_all
LEFT JOIN users ON
users.id = product_tag.lang
LEFT JOIN images ON
images.id = ps_product_tags_all.lang

Error:

Unknown column 'product_tag.lang' in 'on clause'
2
  • Does lang actually exist in the product_tag table ;-) Commented Sep 10, 2010 at 8:12
  • please post the table structure and whole query then. Commented Sep 10, 2010 at 8:13

2 Answers 2

4

You are mixing implicit and explicit joins and joining in the wrong order. Try this:

SELECT *
FROM ps_product_tags_all
LEFT JOIN images ON
images.id = ps_product_tags_all.lang, product_tag
LEFT JOIN users ON
users.id = product_tag.lang
WHERE ...

Remember that explicit JOIN has higher precedence than the implicit join from using comma. To avoid this error I would recommend that you always use explicit joins:

SELECT *
FROM ps_product_tags_all
LEFT JOIN images ON images.id = ps_product_tags_all.lang
LEFT JOIN product_tag ON ...
LEFT JOIN users ON users.id = product_tag.lang
Sign up to request clarification or add additional context in comments.

1 Comment

good to know, i've always joined without that info and never had such problem. ;]
2

This is not syntax error, but structure error - you don't have "lang" column in "product_tag" table.

1 Comment

This probably isn't the reason why the query is failing.

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.