The problem isn't with GROUP_CONCAT
, the problem is that your WHERE
clause is only selecting one row. Since the lookupId
field is an integer, it's converting the string '177,178'
to an integer, which is just 177
. You shouldn't have quotes around the values in the IN()
list, that's making it just a single value to look for.
SELECT GROUP_CONCAT(abc.displayValue SEPARATOR ' ')
FROM abc
WHERE abc.lookupId IN (177, 178)
If the comma-separated string is actually coming from a column in a table you're joining with, see sql join tables where 1 column has comma.
SELECT GROUP_CONCAT(table1.displayValue SEPARATOR ' ')
FROM table1
JOIN table2 ON FIND_IN_SET(table1.lookupID, table2.lookupIDs)
WHERE ...