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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:35:53+00:00 2026-06-13T04:35:53+00:00

I have data from two tables in a members system as follows: Table: listuser

  • 0

I have data from two tables in a members system as follows:

Table: listuser
userid  listid
===========
1       5
1       8
1       3
2       5
2       3
3       4
4       4
5       3
6       4

Table: list
id  name
==============
3   Members
4   Non Members
5   Subscribers
8   Test

What I am trying to achieve is a result as follows:

userid  lists
===================
1       Members, Subscribers, Test,
2       Members, Subscribers
3       Non Members,
4       Non Members,
5       Members,
6       Non Members,

Users can belong between 0 and n lists.
I have tried a number of approaches, but always end up with multiple rows for userid which is what I am trying to eliminate. I would be very great full for some help.

  • 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-13T04:35:54+00:00Added an answer on June 13, 2026 at 4:35 am

    Try this. It will help you

    SELECT DISTINCT lu2.userid,(
    SELECT ISNULL(l1.name, '') + ', '
    FROM dbo.listuser lu1 JOIN dbo.list l1 ON lu1.listid = l1.id
    WHERE lu1.userid = lu2.userid 
    FOR XML PATH('')) AS name
    FROM dbo.listuser lu2
    ORDER BY lu2.userid
    

    Example on SQL Fiddle

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

Sidebar

Related Questions

I want to get data from two tables. I have patient first name and
I have data in two tables that I want to query from. Each table
I am trying to join data from two tables where the userid from table
I have some data from two tables: Table prod_schedule Line Model Lot_no Quantity Lot_Quantity
I have an INSERT query that is pulling data from two tables and inserting
I have a vb.net 2010 form with 22 data bound controls from two tables
I have two different tables from which I need to pull data blogs which
I have two tables users registered_members I want to confirm values from user table
I currently have a fairly long LINQ statement which pulls data from two tables:
I have two tables called visits and members and i am getting the data

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.