Table one - workorder
╔══════════╦══════════════╦══════════════╗
║ id ║ wpeople ║ start_date ║
╠══════════╬══════════════╬══════════════╣
║ 1 ║ 1,2,4 ║ 02.08.2016 ║
║ 2 ║ 4,5 ║ 28.09.2016 ║
╚══════════╩══════════════╩══════════════╝
Table two - employees
╔══════════╦═════════════════╗
║ id ║ name ║
╠══════════╬═════════════════╣
║ 1 ║ John ║
║ 2 ║ Ben ║
║ 3 ║ Ian ║
║ 4 ║ Hank ║
║ 5 ║ George ║
╚══════════╩═════════════════╝
Output selection for who need to work at the project
╔══════════╦════════════════╦════════════╗
║ 1 ║ John,Ben,Hank ║ 02.08.2016 ║
║ 2 ║ Hank,George ║ 28.09.2016 ║
╚══════════╩════════════════╩════════════╝
I have tried with GROUP_CONCAT and FIND_IN_SET
SELECT w.id,
GROUP_CONCAT(e.name ORDER BY e.id) workorder
FROM workorder w
INNER JOIN employees e
ON FIND_IN_SET(e.id, a.wpeople) > 0
GROUP BY w.id
But the output it's
╔══════════╦════════════════╦════════════╗
║ 1 ║ John ║ 02.08.2016 ║
║ 1 ║ Ben ║ 02.08.2016 ║
║ 1 ║ Hank ║ 02.08.2016 ║
║ 2 ║ Hank ║ 28.09.2016 ║
║ 2 ║ George ║ 28.09.2016 ║
╚══════════╩════════════════╩════════════╝
I search on google for this and the solution it's GROUP_CONCAT - FIND_IN_SET. Can be that I didn't understand very well this function.
Thanks for you time! Stefan