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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:12:38+00:00 2026-06-16T04:12:38+00:00

I have a table (Table D ) that has a field that has another

  • 0

I have a table (Table D) that has a field that has another table (Table M) associated with it which contains a set of rows that reference a single row in table D.

Can (and if so, how) can I create a SQL Query that will not only select the fields from D, but join with table M, returning all the row values (only from one column) in a single result column, but all concatenated together (preferably with some sort of escaping so it can’t be contaminated by rogue data in M)?

EDIT:

+-----------+----------+-------------+
| DataRowID | DataName | RandomField |
+-----------+----------+-------------+
| 1         | Foo      | Alice       |
+-----------+----------+-------------+
| 2         | Bar      | Bob         |
+-----------+----------+-------------+
| 3         | Baz      | Charlie     |
+-----------+----------+-------------+


+-----------+-----------+-----------+
| MetaRowID | DataRowID | MetaValue |
+-----------+-----------+-----------+
| 1         | 1         | Mercury   |
+-----------+-----------+-----------+
| 2         | 1         | Venus     |
+-----------+-----------+-----------+
| 3         | 1         | Earth     |
+-----------+-----------+-----------+
| 4         | 2         | Mars      |
+-----------+-----------+-----------+
| 5         | 2         | Jupiter   |
+-----------+-----------+-----------+
| 6         | 3         | Saturn    |
+-----------+-----------+-----------+
| 7         | 3         | Uranus    |
+-----------+-----------+-----------+
| 8         | 3         | Neptune   |
+-----------+-----------+-----------+
| 9         | 3         | Pluto     |
+-----------+-----------+-----------+

Which when Where DataName = 'Bar' is Queried,

+-----------+----------+-------------+--------------+
| DataRowID | DataName | RandomField | MetaData     |
+-----------+----------+-------------+--------------+
| 2         | Bar      | Bob         | Mars,Jupiter |
+-----------+----------+-------------+--------------+
  • 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-16T04:12:39+00:00Added an answer on June 16, 2026 at 4:12 am

    Use MySql’s GROUP_CONCAT function:

    SELECT d.ID, GROUP_CONCAT(m.Field) AS ConcatFields
    FROM d JOIN m ON d.ID = m.dID
    GROUP BY d.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server 2005 table that has a varchar(250) field which contains
I have a table which has a field called Sold , in that field
I have a SQL database that has a table with a field set to
I have a table 'comment', investigation that has a field referencing another table 'sf_guard_user'.
I have a MySQL table that has a field of comma separated values. How
I have a table contacts that has a field arrayOfMembers (JSON format) and a
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I have a simple table (lets call it Table1) that has a NVARCHAR field
I have one table that has two fields - ID1 and ID2 ID1 can
I have a table that has multiple rows with the following fields: PersonName SongName

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.