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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:38:47+00:00 2026-06-05T23:38:47+00:00

I have some tables that I’m joining in a query with Postgres (9). However,

  • 0

I have some tables that I’m joining in a query with Postgres (9).

However, as it’s a many to many relationship, I’m getting lots of records where I have a record for table A, and then the items for table B (as expected). For instance:

Car, Ford
Car, BMW
Car, VW
Bike, Yamaha
Bike, BMW
Bike, Honda

What I’m after is getting the relationship as a list:

Car, "Ford, BMW, VW"
Bike, "Yamaha, BMW, Honda"

Is this possible with Postgres in a normal query, or do I need to do something more magic?

  • 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-05T23:38:49+00:00Added an answer on June 5, 2026 at 11:38 pm
    select a.type,
           string_agg(b.name, ',');
    from a 
      join b on a.id = b.type_id
    

    You will need to replace the column and table names with the real ones (which you have not provided so I can’t use the correct ones here).

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

Sidebar

Related Questions

I have some tables that benefit from many-to-many tables. For example the team table.
I have some Oracle tables that represent a parent-child relationship. They look something like
I want to do a search across 2 tables that have a many-to-one relationship,
I'm getting sick with this problem. I have some tables that have contentes launched
Greetings, I have some mysql tables that are currently using an md5 hash as
I have some transliteration tables in code that are formated to make it easier
I'm using MySQL 4.1. Some tables have duplicates entries that go against the constraints.
I have some PHP code that generates dynamic tables of data on the fly.
I have a tables 'players' and 'awards'. I have some duplicate player entries that
I have 2 tables with some columns and another table that I want its

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.