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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:21:56+00:00 2026-05-11T04:21:56+00:00

Say I have 2 tables, A and B, each A entity can possibly have

  • 0

Say I have 2 tables, A and B, each A entity can possibly have multiple B entities, in one case if I want to get all B’s of some certain A’s, I might do it with a simple left join

select A.id aid,B.id bid from A left join B on B.aid = A.id where A.id = 1 

and it will return a result set like

aid   bid 1     1 1     2 1     3 

As you can see for the first column, all those 1’s are kinda duplicates. Is it possible to modify the SQL statement to let him return a result like

aid    bid  1      1,2,3 

in other words to link all the bid’s together as one entity?

Also what if there’s another table C, and each A can have multiple C’s, how to I make the SQL return a result set like

 aid    bid    cid   1     1,2,3   1,2 

instead of

 aid     bid    cid   1       1      1   1       2      1   1       3      1   1       1      2   1       2      2   1       3      2  

Thank you very much!

  • 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. 2026-05-11T04:21:57+00:00Added an answer on May 11, 2026 at 4:21 am

    What DBMS are you using?

    I can’t speak for others, but in MySQL, starting from 4.1, you can use GROUP_CONCAT

    http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

    EG:

    select A.id aid, GROUP_CONCAT(DISTINCT B.id) bid from A left join B on B.aid = A.id where A.id = 1 GROUP BY a.id 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two tables I want to join. Categories: id name ---------- 1
Say I have 2 tables: Customers and Orders. A Customer can have many Orders.
Lets say I have two tables - child and parent with many-to-one relation. What
Quick question that requires a long explanation.. Say I have two tables - one
7 tables. In each table there is a common entity called fisherid. I have
I have 2 tables (entity) a person entity and a vacation entity. One person
Say I have at database table containing information about a news article in each
Say we have two tables in an MS Access db: Service Users: | ID
Say I have two tables called A (fields: id, phase, name) and B(fields: id,
Say I have three tables: Fruit (Table 1) ------ Apple Orange Pear Banana Produce

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.