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

  • SEARCH
  • Home
  • 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 9183023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:42:03+00:00 2026-06-17T18:42:03+00:00

Struggling a bit with MySQL. I’ve found the GROUP_CONCAT function which looks right for

  • 0

Struggling a bit with MySQL. I’ve found the GROUP_CONCAT function which looks right for my needs, but I can’t work out how to use it. What I’d like to do is search in several columns as well as the concat column; so if any of the columns equal my search term (%a% in this example) it should be returned. I’ve worked out how to return the concatenated genre string but I can’t work out how to search on it.

SELECT albumArtworkURL, albumName, albumID, 
  b.artistID AS ArtistID, b.artistName AS ArtistName,
  GROUP_CONCAT(DISTINCT c.songGenre separator ',') AS genres
FROM album
LEFT JOIN artist b ON album.albumArtist = b.artistID
LEFT JOIN song c ON albumID = c.songOnAlbum
WHERE albumName LIKE '%a%' OR albumYear LIKE '%a%'
GROUP BY albumArtworkURL, albumName, albumID, ArtistID, ArtistName
ORDER BY albumYear ASC, albumName ASC

Would really appreciate some help. Thanks 🙂

  • 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-06-17T18:42:05+00:00Added an answer on June 17, 2026 at 6:42 pm

    If you want to search on the result of the GROUP_CONCAT(), then you could wrap your query in another select:

    SELECT *
    FROM
    (
      SELECT albumArtworkURL, 
        albumName, 
        albumID, 
        b.artistID AS ArtistID, 
        b.artistName AS ArtistName,
        GROUP_CONCAT(DISTINCT c.songGenre separator ',') AS genres
      FROM album
      LEFT JOIN artist b 
        ON album.albumArtist = b.artistID
      LEFT JOIN song c 
        ON albumID = c.songOnAlbum
      GROUP BY albumArtworkURL, albumName, albumID, ArtistID, ArtistName
    ) src
    WHERE albumName LIKE '%a%' 
      OR albumYear LIKE '%a%'
      OR genres LIKE  '%a%'
    ORDER BY albumYear ASC, albumName ASC
    

    But unless I am missing something in your explanation, I don’t know why you can’t just search on the songGenre instead of the concat version of it:

    SELECT albumArtworkURL, 
      albumName, 
      albumID, 
      b.artistID AS ArtistID, 
      b.artistName AS ArtistName,
      GROUP_CONCAT(DISTINCT c.songGenre separator ',') AS genres
    FROM album
    LEFT JOIN artist b 
      ON album.albumArtist = b.artistID
    LEFT JOIN song c 
      ON albumID = c.songOnAlbum
    WHERE albumName LIKE '%a%' 
      OR albumYear LIKE '%a%'
      OR songGenre LIKE '%a%'
    GROUP BY albumArtworkURL, albumName, albumID, ArtistID, ArtistName
    ORDER BY albumYear ASC, albumName ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

struggling a bit to get the following to work : I'm trying to merge
Struggling to get any list function to work. I've been fine with _show and
I'm struggling a bit figuring out the best way accept and store a url
I'm struggling a bit to find the right place for a helper method. The
at work I am struggling a bit with the following situation: We have a
Struggling a bit with HTML positioning. I'm sure it's a pretty simple problem, but
I am struggling a bit with how I can unit test parsing a file...
I'm a bit struggling with the setup of my models. I have companies which
I'm currently working on a MySQL query, but I've been having a bit of
I'm struggling a bit with an excel calculation that needs to be written 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.