Solved

help with group_concat

Posted on 2011-02-15
4
855 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

12 Experts available now in Live!

Get 1:1 Help Now