Apply WHERE
condition to get EmployeeID
from Location
table:
SELECT
Employee.*,
GROUP_CONCAT(Location.City)
FROM
Employee
INNER JOIN Location
ON Employee.ID=Location.EmployeeID
INNER JOIN
(SELECT DISTINCT
EmployeeID
FROM
Location
WHERE
City IN ('Berlin', 'Stuttgart')) AS IDS
ON Employee.ID=IDS.EmployeeID
GROUP BY
Employee.ID
-check the fiddle.
Alternative solution would be to use HAVING
clause with plain query and INSTR()
, for example, but I don't recommend you to do it because comparing in HAVING
will be slow and, besides, list of values will produce multiple comparisons.