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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:41:51+00:00 2026-06-03T08:41:51+00:00

I have an issue with processing data with PHP I retrieved from MySQL. This

  • 0

I have an issue with processing data with PHP I retrieved from MySQL. This is the table schema:

parents:
id | firstname | lastname

children:
id | firstname | lastname

parent_child_link
child_id | parent_id

I need to save the data this way, because I’d like to link multiple parents to one child. Now when I want to retrieve a child, I’d like to get all the information of the child, but also the parent id’s. This obviously is a JOIN query, so I use:

SELECT *
FROM children c
JOIN parent_child_link l on l.child_id=c.id
WHERE c.id=1

Now, when this child with id=1 has 2 parents (lets say with id’s 1 and 2), I get this as a result:

id | firstname | lastname | parent_id
1    test        test       1
1    test        test       2

If I process this in PHP, I would get 2 arrays, but I want this in one array, e.g.

array(
    'firstname' => 'test', 
    'lastname' => test',
    'parents' => array(1, 2)
)

How can I achieve this?

Thanks a lot!

  • 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-03T08:41:53+00:00Added an answer on June 3, 2026 at 8:41 am

    You can use GROUP_CONCAT to return a comma seperated array of the values

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

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

Sidebar

Related Questions

I have a script to extract certain data from a much bigger table, with
I have an issue with php where code works on on computer but wont
I have the following code: for (i=1;i<=pages;i++) { $('#procout').append(Processing Page#+i+<br />); $.ajax({ url: 'processor.php',
I'm having a problem reading and processing data from my server. I've spent hours
We have legacy C++ code performing high-performance data processing (e.g., large volumes of data
I'm trying to debug an issue. We have few Threads that work on data
I currently do alot of data parsing, and have toyed with PHP functions for
We have a cube that we are populating the data from the source tables.
I am having an issue when processing form data. When the form is submitted,
I have a MySQL database with a PHP front-end. I would like to implement

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.