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

  • Home
  • SEARCH
  • 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 6640131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:38:14+00:00 2026-05-25T23:38:14+00:00

I am trying to make a new view using in MSSql 2008 from three

  • 0

I am trying to make a new view using in MSSql 2008 from three tables:
Table 1 has customer id and transaction id
Table 1

CustomerID      TransactionID   
1                        1
1                        2

Table 2 has Purchases Transaction and Products ID

TransactionID    ProductID 
1                     x
2                     y

Table 3 has Products Names

ProductID   Name  
1            x
2            y

I view I would like to make should show

CustomerID  Product Name
1              x, y

When I use the following query:

SELECT     table1. CustomerID, table3.Name 

FROM         table1 LEFT OUTER JOIN
                      Table2 ON table2. TransactionID    = table1.VisitId LEFT OUTER JOIN
                      Table3 ON table2. ProductID  = Table3. ProductID 

                      GROUP BY table1. CustomerID, table3.Name

I get

CustomerID  Product Name
1           x
1           y

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-25T23:38:14+00:00Added an answer on May 25, 2026 at 11:38 pm

    One way to do this is to use a user defined function, something like:

    SELECT table1.CustomerID, dbo.BuildStringOfCustomerProductNames(table1.CustomerID)
    FROM table1
    

    And create a user defined function like: dbo.BuildStringOfCustomerProductNames
    that takes a customerid as input.
    Inside there, you can run a query to loop through the table 2 and table 3 joined records to make a string, and return that.

    Off hand I can’t think of any other simple way to do it.

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

Sidebar

Related Questions

I'm trying to make a listview from an arraylist using the tutorial i found
I'm trying to make a push animation from one side using a CATransition .
I'm trying to make a new CLLocation subclass. This is the skeleton: #import <UIKit/UIKit.h>
I'm trying to make a new wx.Choice-like control (actually a replacement for wx.Choice) which
I don't know alot about ASP.Net but I'm trying to make a new control
I'm new to BIRT and I'm trying to make the Report Engine running. I'm
I am trying to make a copy of a database to a new database
I am trying to make a firefox extension which looks at all the new
I am trying to make a blackjack game where before each new round, the
I'm rather new to jQuery and I'm trying to make a cool little menu

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.