Solved

help with group_concat

Posted on 2011-02-15
4
856 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:andieje
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 34899453
please try:
select group_concat(col) `temp` from table group by id having group_concat(col) REGEX 'test' ;

Open in new window

0
 

Author Comment

by:andieje
ID: 34899944
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
 
LVL 40

Assisted Solution

by:Sharath
Sharath earned 250 total points
ID: 34900037
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
 

Author Closing Comment

by:andieje
ID: 34900237
I'd missed off the 'P'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now