mysqlleft-joinmysql-5.7

Syntax Error when adding a LEFT JOIN to a SELECT-FROM-WHERE


inscription

"inscription" table

diver

"diver" table

This is OK:

SELECT id_membre, id_sortie, id_diver, licence, mail, actif
FROM inscription
WHERE id_sortie = 4071

When I add the LEFT JOIN it crashes:

SELECT id_membre, id_sortie, id_diver, licence, mail, actif
FROM inscription
WHERE id_sortie = 4071
LEFT JOIN diver ON inscription.licence = diver.licence;

#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 diver ON inscription.licence = diver.licence LIMIT 0, 30' at line 3


Solution

  • Correct syntax :

    SELECT id_sortie, id_diver, inscription.licence, mail, actif
    FROM inscription
    LEFT JOIN diver ON inscription.licence = diver.licence
    WHERE inscription.id_sortie = 4071;