I have 3 tables.
tb_employees:
+---------------+---------------+
| id_employee | employee |
+---------------+---------------+
| 1 | Robert Tomson |
| 2 | Jhonatan Weg |
| 3 | Eva Uhte |
+---------------+---------------+
tb_requirements:
+---------------+-----------------+
| id_requirem | requirem |
+---------------+-----------------+
| 11 | Photo |
| 12 | Criminal Record |
| 13 | Shooting Test |
+---------------+-----------------+
tb_details:
+---------------+-----------------+---------------+
| id_details | id_employee | id_requirem |
+---------------+-----------------+---------------+
| 21 | 1 | 11 |
| 22 | 1 | 12 |
| 23 | 1 | 13 |
| 24 | 2 | 12 |
| 25 | 2 | 13 |
| 26 | 3 | 11 |
| 27 | 3 | 13 |
+---------------+-----------------+---------------+
What I have to do is a SELECT of requirem (the description) and an specific employee (for exm. WHERE id_employee = '2') and ADD a 'virtual column' that shows if the employee has that requirement or not.
Like This: WHERE id_employee = '2'
+----------------+-----------------+
| requirem | virtual_column |
+----------------+-----------------+
| Photo | 0 |
|Criminal Record | 1 |
| Shooting Test | 1 |
+---------------+------------------+
WHERE id_employee = '3'
+----------------+-----------------+
| requirem | virtual_column |
+----------------+-----------------+
| Photo | 1 |
|Criminal Record | 0 |
| Shooting Test | 1 |
+---------------+------------------+
Where 0 = Employee doesn't have that requirement, 1 = Employee has that requirement : from the tb_detail.
I really don't have an idea how to do this.
Can u help me please?
Thank you for answers.