-1

I am new to databases;

I am trying to query (SELECT) naam, functie and schaal (salary-scale) of an employee.

But there is a catch, because naam and functie are within the table: "werknemer" and scale is in the table "s_schaal".

Here is an image of the ERD:

What I think needs to happen is the following: The employees salary should be looked at and then compared to "ondergrens" and "bovengrens", if employees salary is equal to or between one of the entries then the correlating "schaal" should be outputted as well.

In order to SELECT wnaam, functie, schaal (corrrelating scale which is in another table).

This is what I tried:

SELECT werknemer.wnaam, werknemer.functie, s_schaal.schaal WHERE werknemer.salaris IS >= s_schaal.ondergrens AND werknemer.salaris IS <= s_schaal.bovengrens

This is the error message

INSERT INTO werknemer SELECT * FROM s_schaal WHERE werknemer.salaris = s_schaal.ondergrens AND werknemer.salaris = s_schaal.bovengrens Error Code: 1054. Unknown column 'werknemer.salaris' in 'where clause' 0.000 sec

Shadow
  • 33,525
  • 10
  • 51
  • 64
Liza Darwesh
  • 401
  • 1
  • 3
  • 20

1 Answers1

-1

You need a left [outer] join to do that, as in:

select w.wnaam, w.functie, s.schaal
from werknemer w
left join s_schaal s 
  on w.salaris >= s.ondergrens and w.salaris <= s.bovengrens
The Impaler
  • 45,731
  • 9
  • 39
  • 76