Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't figure out this syntax error in SQL SELECT statement

I have been trying to get a simple SELECT statement to work but I keep getting a syntax error on the LEFT JOIN. The code:

SELECT
p.player_name,
s.country_name
FROM player_mast p
WHERE p.team_id=1217
LEFT JOIN soccer_country s ON p.team_id = s.country_id;

Seems pretty simple i guess, but it keeps giving me this error:

Error Code: 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 ‘LEFT JOIN soccer_country AS s ON p.team_id =
s.country_id’ at line 6

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m using MySQL 8.0 and I have checked the documentation. I am a beginner with SQL so I’m sure I’m missing something obvious, but I just can’t figure out what..

Help is much appreciated.

>Solution :

JOIN clause should come before the WHERE clause.

SELECT
p.player_name,
s.country_name
FROM player_mast p
LEFT JOIN soccer_country s ON p.team_id = s.country_id
WHERE p.team_id=1217;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading