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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:17:45+00:00 2026-05-25T16:17:45+00:00

I got to tables. TABLE 1: [..fields..] [CATEGORIE] [..fields..] TABLE 2: [..fields..] [ID] [CATEGORIE]

  • 0

I got to tables.

TABLE 1: [..fields..] [CATEGORIE] [..fields..]

TABLE 2: [..fields..] [ID] [CATEGORIE] [..fields..]

I want to connect a bit special and tried it like this:

SELECT [..other fields..], CATEGORIE, (SELECT ID FROM TABLE2 WHERE TABLE2.CATEGORIE = TABLE1.CATEGORIE) FROM TABLE1;

I want to have the IDs of the SubQuery in on Column of the Main Query

like that ( [] are representing columns)

[resultfield1] [resultfield2] [resultfield3] [ID1,ID2,ID3,ID4,…]

is there a way to afford it?

Help is very appreciated,

thanks in advance

  • 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-05-25T16:17:46+00:00Added an answer on May 25, 2026 at 4:17 pm

    As hard as it is to read understand your question, what you want is to use FOR XML PATH:

    select 
        categorie, 
        stuff((select ', ' + id
               from table2 t2 where t1.categorie = t2.categorie
               for xml path('')),
              1,2,'') [IDs]
    from table1 t1
    

    Further reading here:

    • SQL Query to get aggregated result in comma seperators along with group by column in SQL Server
    • SQL same unit between two tables needs order numbers in 1 cell
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a table in MS Access 2007 with 4 fields. Labour Cost
I've got a table with a header, a row with input fields, rows with
I got a query with five joins on some rather large tables (largest table
I've got MS Access database with linked tables, whenever each table is linked to
Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID
I am developing an Rails 3 API and in this API I got tables
I got two tables: CREATE TABLE IF NOT EXISTS `groups2rights` ( `groups2rights_group_id` int(11) NOT
I've got a series of comboboxes made from ASP.NET DropDownLists (populated from a select
ok, this is bugging me. i got a phonebook DB from a client where
My java/groovy program receives table names and table fields from the user input, 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.