Solved

help with group_concat

Posted on 2011-02-15
4
872 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

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 41

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

Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

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 …
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

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