I have two tables
Reports
id consultants
1 1,2,3,4
Users
id name
1 John
2 Tom
When I try to run this query I get an error: "Unknown column 'reports.consultants' in 'where clause'"
SELECT reports.id,
(SELECT GROUP_CONCAT(name SEPARATOR ", ") from (SELECT name from users where users.id in (reports.consultants)) a) as consultant
FROM reports
I've thought of using a separate ReportConsultants table but I thought storing the consultants in the reports table may make the query more efficient and wondering if there is a way to do this. Using this kind of structure is also much simpler in the code.