Skip to content
Advertisement

MySQL: Join three tables, comparing two values

First of all, I’m an amateur on SQL. Here it is the example. From this three tables I would like to know who are the teachers that make more money than Mike

Table1:

Table2:

Table3:

So far I’ve made this:

And I don’t know how to keep going because when I run it, an error appears.

My expected result would be something like:

Thanks!

Advertisement

Answer

In your main query you must use a HAVING clause instead of a WHERE clause and also in the subquery fix your joins:

See the demo.
Results:

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