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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:08:29+00:00 2026-06-11T06:08:29+00:00

I have to join multiple tables, some with one to many mappings, and convert

  • 0

I have to join multiple tables, some with one to many mappings, and convert every entry in the joined table to a single row entry in a csv file using PHP.

I know I am basically going from a 3D to 2D representation, but it is a formatting requirement for the csv file.

The MySQL structure consists of tables “questions”, “people” and “trips”. “people” table is linked to “questions” table by the id of “questions”. Also in the same way “trips” is linked to “people” by the id of “people”. There are one to many relationship between both “questions” to “people” and “people” to “trips”

The idea is to have a csv file with one “question” entry per row. This row entry will be the joined result of all 3 tables. The number of people and trips per questions entry is not consistent, therefore spaces are required if there are fewer people in some “questions” entries than other. The same with the trips.

What is the best way to get this done in PHP, except for brute force coding this with many queries, for loops etc. I am trying to get the MySQL query going, but cannot wrap my head around this problem.

  • 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-11T06:08:30+00:00Added an answer on June 11, 2026 at 6:08 am

    I think you’re looking for mysql GROUP_CONCAT function.

    Select data with joins, group it by question_id and use group_concat on people and trips columns.

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

Sidebar

Related Questions

I have a dynamic search query with join multiple tables, for showing sum and
I have a mysql query that uses union to join multiple queries into one
I have used a join query for retrieving value from two tables one is
I have three tables, table one (tableA) containing users data like name and email,
I have a table with a one to many mapping to a table that
I have 2 tables, one lists Properties (Houses, flats etc) and the other table
I have two tables user (one) and transaction (many) and I need to get
I'm trying to join multiple tables, but one of the tables has multiple records
I have two tables, in PostgreSQL if that matters, with one to many relations.
I have some SQL joining multiple tables in Access. When attempting to run it,

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.