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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:40:38+00:00 2026-05-31T10:40:38+00:00

I have 2 tables. Table 1 has Product ID and Product Name (each row

  • 0

I have 2 tables.

Table 1 has Product ID and Product Name (each row has a unique Product ID).

1 Name1
2 Name2
3 Name3

Table 2 has Product ID and Color (Red, Green, Blue) and Price. There can be up to 3 rows with the same Product ID depending on what color the Product ID is associated with.

1 Red $6
1 Blue $2
2 Blue $3
3 Green $5

I want to query to create a new table with the following columns: Product ID, Product Name, RedPrice, GreenPrice and BluePrice. The 2 above samples result in:

1 Name1 $6 Null $2
2 Name2 Null Null $3
3 Name3 Null $5 Null

How do I do this query? Either SQL or Microsoft Access code is fine. Thanks.

  • 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-31T10:40:39+00:00Added an answer on May 31, 2026 at 10:40 am

    Assuming there can be no more than one price of each kind per product:

    SELECT
      products.ProductID,
      products.ProductName,
      red  .Price AS RedPrice,
      green.Price AS GreenPrice,
      blue .Price AS BluePrice
    FROM products
    LEFT JOIN prices red   ON products.ProductID = red  .ProductID AND red  .Color = 'Red'
    LEFT JOIN prices green ON products.ProductID = green.ProductID AND green.Color = 'Green'
    LEFT JOIN prices blue  ON products.ProductID = blue .ProductID AND blue .Color = 'Blue'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table hall_products with products. Each product has a NAME, is sold
i have two tables products and reviews each product has several reviews linked by
I have a table for product category that has a hierarchical structure. Each Category_ID
I have 2 tables. Table_1 has product 3 rows : ID, Quantity and Price.
I have two tables. One has some product details, the other holds various photos
I have a cart table which has a relation to a product table that
I have a table [Product] with a column [CreateTime] datetime null, and is has
I currently have 4 tables. Product, Category, SubCategory, ProductSubCategory. Category has a OneToMany SubCategory
I have an integer column in my table. It is product id and has
I have this three tables: products TABLE: id:integer name:string features TABLE: id:integer name:string features_products

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.