Hi, I'm trying to left join an employee table to a subqueried-trainings table.
Employees Table:
$query= "SELECT * FROM employees WHERE employees.department='Oncology'";
ID -- NAME -- DEPARTMENT
123 -- Joe -- Oncology
456 -- Mary -- Oncology
789 -- Alex -- Oncology
Trainings Table:
$query = "SELECT trainings.id, GROUP_CONCAT(subject) FROM trainings GROUP BY trainings.cid";
This query is necessary to get one row for each ID and the training SUBJECT concated in the following column
ID -- SUBJECT
001 -- apple, orange
123 -- apple, orange, pear
789 -- orange, pear
How do I write a LEFT JOIN so that I get all the people from employees table, then add the SUBJECT column to the matching ID? The result should look like this:
ID -- NAME -- DEPARTMENT -- SUBJECT
123 -- Joe -- Oncology -- apple, orange, pear
789 -- Alex -- Oncology -- orange, pear
Many thanks!!!