SELECT foo, GROUP\_CONCAT (user\_id) as userids
FROM table1
GROUP BY foo 
HAVING userids like foo
--HAVING userids contains foo

For each foo, it may associated to multiple userids. What I would like is to group all of the userids into arrays with foo. 

I want to only show the ones where the userid array contains one userid that also matches foo, which is why I add the HAVING clause. I tried like and contains, both gave me the error in the title. What other options do I have?

I tried the same query without the HAVING clause and it failed as well! So looks like GROUP\_CONCAT is the issue here. 

This is what I want to show.

abc, (abc,dfgdf,46456)