Question

I might be blind on both eyes, but iterating through a lot of versions and tries... Deleted the hyphenation and the AS statements...

I always ended up with a parsing Error 1064 from my MySql5.1 Server. I really believe this is valid, SQL Answers:

Are there any suggestions?

SELECT (dpa_articles.name, [...] corporations.isin) FROM corporations 
NATURAL JOIN corporations_dpa_articles ON (corporations.id = corporations_dpa_articles.corporation_id)
NATURAL JOIN dpa_articles ON (dpa_articles.id = corporations_dpa_articles.dpa_article_id)
NATURAL JOIN dpa_articles_dpa_categories ON (dpa_articles.id = dpa_articles_dpa_categories.dpa_article_id)
WHERE dpa_articles_dpa_categories.dpa_category_id = 28

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON (corporations.id=corporations_dpa_articles.corporation_id) NATURAL JOIN dpa_a' at line 3

Thank you very much in advance.

Was it helpful?

Solution

NATURAL JOIN should not have an ON clause.

The joining condition is implicit and based on column names.

You need INNER JOIN as the column names are different. id will not natural join to corporation_id

OTHER TIPS

Did you try un-wrapping the ON clause in the join statements?

Also, you may want to consider using a different join than a natural join. Natural joins don't give you quite as much control as other join methods, and I am not sure if specifying the column it joins on is even valid. An inner join may be more appropriate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top