I have a DB with two tables:
- employees table: fields = {ID, name}
- turnShift table: fields = {ID, date, ID_employee1, ID_employee2}
Here is an example of this DB.
Using MYSQL, I’d like to execute a SELECT query able to show the names of both employees involved in each turn shift.
The following picture shows the desired query results using the previous db example:
2
Answers
It can be done as follow:
I’d query the
turn_shift
table and join on theemployee
table twice, once for each column of IDs you want to convert to names: