Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4039696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:39:00+00:00 2026-05-20T12:39:00+00:00

I am having a problem with the following query(if this is a duplicate question

  • 0

I am having a problem with the following query(if this is a duplicate question then i’m terribly sorry, but i can’t seem to find anything yet that can help me):

SELECT d.*, GROUP_CONCAT(g.name ORDER BY g.name SEPARATOR ", ") AS members
FROM table_d AS d LEFT OUTER JOIN table_g AS g ON (d.eventid = g.id)
WHERE members LIKE '%p%';

MySQL apparently can’t handle a comparison of GROUP_CONCAT columns in a WHERE clause.
So my question is very simple. Is there a workaround for this, like using sub-query’s or something similar? I really need this piece of code to work and there is not really any alternative to use other than handling this in the query itself.

EDIT 1:

I won’t show the actual code as this might be confidential, I’ll have to check with my peers. Anyway, I just wrote this code to give you an impression of how the statement looks like although I agree with you that it doesn’t make a lot of sense. I’m going to check the answers below in a minute, i’ll get back to you then. Again thnx for all the help already!

EDIT 2:

Tried using HAVING, but that only works when i’m not using GROUP BY. When I try it, it gives me a syntax error, but when I remove the GROUP BY the query works perfectly. The thing is, i need the GROUP BY otherwise the query would be meaningless to me.

EDIT 3:

Ok, so I made a stupid mistake and put HAVING before GROUP BY, which obviously doesn’t work. Thanks for all the help, it works now!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:39:01+00:00Added an answer on May 20, 2026 at 12:39 pm

    Use HAVING instead of WHERE.

    ... HAVING members LIKE '%peter%'
    

    WHERE applies the filter before the GROUP_CONCAT is evaluated; HAVING applies it later.

    Edit: I find your query a bit confusing. It looks like it’s going to get only one row with all of your names in a single string — unless there’s nobody in your database named Peter, it which case the query will return nothing.

    Perhaps HAVING isn’t really what you need here…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a little problem with the following: When I execute this line: echo
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
I'm having the following problem. I created a application context file for spring.net. The
I'm trying to find duplicate keys so that they can be addressed and made
So, I'm having some problems with a MySQL query (see other question ), and
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {
We're having problem with a huge number of legacy stored procedures at work. Do
Having a problem getting a TreeView control to display node images. The code below
Having a problem trying to create a function, as part of a BizTalk helper
Im having a problem with a final part of my assignment. We get in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.