help with group_concat

Hi

Please can you advise the correct syntax as neither of the queries below work. I would like to perform a regex on the results of the group_concat function

select group_concat(col) `temp` from table where temp REGEX 'test' group by id;
unknown column temp in where clause

select group_concat(col) `temp` from table where group_concat(col) REGEX 'test' group by id;
invalid use of group function

thanks
andiejeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
please try:
select group_concat(col) `temp` from table group by id having group_concat(col) REGEX 'test' ;

Open in new window

0
 
andiejeAuthor Commented:
I get a syntax error for any query with

having colnname REGEX 'exp';

or

having group_concat(colname) REGEX 'exp';

after the group by clause
0
 
SharathConnect With a Mentor Data EngineerCommented:
SELECT   Group_concat(col) TEMP 
FROM     table 
GROUP BY id 
HAVING   Group_concat(col) REGEXP 'test';

Open in new window

or
SELECT * 
FROM   (SELECT   Group_concat(col) TEMP 
        FROM     table 
        GROUP BY id) AS t1 
WHERE  TEMP REGEXP 'test';

Open in new window

0
 
andiejeAuthor Commented:
I'd missed off the 'P'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.