For school I have to do this:

Query what salary scale an employee belongs to displaying these columns:

s_schaal.schaal, werknemer.name, werknemer.salaris

But there are no identifiers between the tables. All I have is a bottom line and upper line column (s_schaal.ondergens & s_schaal.bovengrens).

What MySQL query can I use to compare and join this data?


  • Any columns can be used in a JOIN..ON. Indexed columns are better, for performance. FOREIGN KEYs are not required. – Rick James Apr 24 '15 at 4:59

I finally figured that joining these tables would not bring a solution. I solved it doing this:

SELECT S.schaal, W.wnr, W.wnaam, W.salaris FROM Werknemer W, S_schaal S 
WHERE W.salaris >= S.ondergrens && W.salaris <= S.bovengrens;
  • 1
    This is a join, without a JOIN. – ypercubeᵀᴹ Apr 23 '15 at 21:03
  • I also discovered that, when using the ON clause in a join, you don't have to make the PK+FK comparison. You can also make it like this: ON W.salaris <= S.bovengrens AND W.salaris >= S.ondergrens – Lee Apr 23 '15 at 21:05
  • Right. Or: ON w.salars BETWEEN s.ondergrens AND s.bovengrens – ypercubeᵀᴹ Apr 23 '15 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.