Solved

help with group_concat

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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