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 8565945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:32:42+00:00 2026-06-11T17:32:42+00:00

Coming up with the correct title for this was a bit challenging. So I’ve

  • 0

Coming up with the correct title for this was a bit challenging.

So I’ve got a user profile table, a music genres table, and a genre_profiles table for the one to many association. Below I’ve got a group_concat that returns all the genreName for a profile, but there is a problem. I want to return all the genres for a profile even when I’m filtering for a specific genre like genreID 15.

SELECT *, group_concat(cast(g.genreName as char) SEPARATOR ', ') as genreName 
FROM profiles p 
LEFT OUTER JOIN genre_profiles gpro ON gpro.profileID = p.profileID 
LEFT OUTER JOIN genres g ON g.genreID = gpro.genreID
WHERE gpro.genreID = '15' 
GROUP BY p.profileID

How do I go about filtering my query for a genreID leaving the genreNames associated with a profile intact? Should I do a subquery for all the profiles with a profileID of 15 and then get all the genre data from that?

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-11T17:32:43+00:00Added an answer on June 11, 2026 at 5:32 pm

    So I think this solves my problem.

    SELECT * , GROUP_CONCAT( CAST( g.genreName AS CHAR ) SEPARATOR  ', ' ) AS genreName
    FROM profiles p
    LEFT OUTER JOIN genre_profiles gpro ON gpro.profileID = p.profileID
    LEFT OUTER JOIN genres g ON g.genreID = gpro.genreID
    WHERE gpro.isInfluence =  '0'
    AND p.profileID IN 
    (SELECT gp.profileID
    FROM genre_profiles gp
    WHERE genreID = 10)
    GROUP BY p.profileID
    

    It works in all my test cases.

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

Sidebar

Related Questions

Is there a leak in this C code? Although the answer is coming correct,
I have two tables structured like this: table a id title date 1 testing1
Coming from a Relational world things are obviously very different with the Azure Table
I have 2 arrays - one array is coming from the database, another from
How do i validate $_GET thats the number coming from correct source. My url
I'm looking at this code of the correct way to do a singleton in
I'm a bit stuck here with a simple question: I have objects (coming via
I am rendering button in ASP.Net using the below HTML code <table onclick= title=Add
I am having some issues coming up with the correct answer using OpenSSL's BIGNUM
It was difficult to choose correct title, but here is the problem: I've an

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.