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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:17:56+00:00 2026-05-27T14:17:56+00:00

I hope someone can help, I’ve been trawling SO for hours and can’t find

  • 0

I hope someone can help, I’ve been trawling SO for hours and can’t find an answer that does what I need (or at least I can’t see how the answers apply to my situation)

So I have 3 tables, Horses, owners, and horse_owners

Table: horses
ID    Name    age
1     arkle   3
2     shergar 4
3     daisy   2

Table: owners
ID    Name   
1     Joe
2     Jack
3     Susan
4     Mike

Table: horse_owners
owner_id    horse_id
1           1
2           1
3           1
4           2

There are other fields but for the sake of simplicity I’ve removed them.
I want to run a query that lists the horses, and their owners (if they have any).

Here’s what I have now:

SELECT 
  h.id, 
  h.name, 
  h.age 
  GROUP_CONCAT(o.name separator ', ') as owners
FROM 
  horses h
LEFT JOIN 
  horse_owners ho 
ON 
  h.id = ho.horse_id
LEFT JOIN
  owners o
ON
  ho.owner_id = o.id

I’m using the group_concat function to combine the owners names where some have multiple owners. But the problem is the query only returns horses that have owners. I want to see all horses whether they have owners or not.

  • 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-27T14:17:57+00:00Added an answer on May 27, 2026 at 2:17 pm
    select 
      h.id, 
      h.name, 
      h.age,
      coalesce(group_concat(o.name order by o.name separator ', '),'Nobody') as owners
    from 
      horses h
    left join 
      horse_owners ho 
    on 
      h.id = ho.horse_id
    left join
      owners o
    on
      ho.owner_id = o.id
     group by h.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can help me find an answer. I'm working with a legacy
hope someone can help me on this as been stuck for hours. I am
I hope someone can help me with this, as I'm unable to find the
I am having a JQuery/ASP issue that I hope someone can help me with.
I hope someone can help me as I've already spent several hours trying to
I hope someone can help me out. I have a table that logs our
Hope someone can help, I'm not a programmer, but have been interested in exploring
Really hope someone can help me or at least point me in the right
I hope someone can help... This issue has been discussed here and I have
Hope someone can help with this. I've been up and down the web and

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.