Skip to content
Advertisement

Mysql : can’t figure out what’s wrong with this LEFT JOIN query

I would like to do a left join on the same table (licence) that only gives me licences that have no entry in the joined table. But I can’t get any result 🙁

Here is the query (quite simple actually) :

The idea is to get only licences that has changed of league in the same year (I omitted the year’s condition on purpose, to simplify the query).

Any idea would be apreciated.

As suggested by https://stackoverflow.com/users/236345/alfabravo, here is my structure:

As for licence_type (to aswer to https://stackoverflow.com/users/1144035/gordon-linoff), it’s just a type like “competition”, or “training”, etc…

Advertisement

Answer

If you use left join you should not use left joined table’s columns in where clause, in this way work as inner join, then add to condition the ON clause

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement