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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:19:31+00:00 2026-06-18T15:19:31+00:00

Hey guys I am this close in being able to represent the data that

  • 0

Hey guys I am this close in being able to represent the data that I wish to display
The column in question is a.state_Id.
I understand from the research I have done that the a.State_Id is out of scope. What is the missing piece to my sql statement?

If I take out the a.State_ID = c.State_Id leaving only the b.Product_Id = c.Product_Id then the data is displayed but I need to match against the state and product.

I know i need to add in another join somewhere but im not sure how. If anyone could help me that would be awesome!

SELECT a.state_id, 
       a.state_name, 
       a.state_abbreviatedname, 
       b.product_id, 
       b.product_name, 
       c.stateproduct_price 
FROM   states a, 
       products b 
       LEFT OUTER JOIN stateproducts c 
ON a.state_id = c.state_id AND b.product_id = c.product_id 

Update 1

The states table has been populated and contains the following fields:

State_Id
State_Name
State_AbbreviatedName

The Products table which has been populated to contain the base products. This table has the following fields:

Product_Id
Product_Name

Each state will have the same products however the price for each product changes with each state. This is why i have the StateProducts table. This table is empty and will be populated one by one by an interface I have created. The statesproducts table will have the following fields

State_Id //reference/relational field to be user for comparison
Product_Id //reference/relational field to be user for comparison
StateProduct_Price //new field

so i understand that i will receive NULL values in the price column.

I have been able to return a sort of cartesion product of the States and products table. However I now need to append the price for each combination on the right side of this cartesion table.
bearing in mind that stateproducts table is empty how would i accomplish this?

  • 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-18T15:19:32+00:00Added an answer on June 18, 2026 at 3:19 pm

    I guess you have a Many-to-Many relationship in which States can have multiple Products and Products can be on different States. So you need to join States into the mapping table StateProducts so you can be able to get the products on table Products.

    SELECT  a.State_ID, 
            a.State_Name, 
            a.State_AbbreviatedName, 
            b.Product_Id, 
            b.Product_Name, 
            c.StateProduct_Price
    FROM    States a
            INNER JOIN StateProducts c
                ON a.State_ID = c.State_Id
            INNER  JOIN Products b 
                ON b.Product_Id = c.Product_Id
    

    To further gain more knowledge about joins, kindly visit the link below:

    • Visual Representation of SQL Joins

    UPDATE 1

    use CROSS JOIN keyword,

    SELECT a.state_id, a.state_name, a.state_abbreviatedname, b.product_id, b.product_name, c.stateproduct_price 
    FROM   states a 
           CROSS JOIN products b 
           LEFT OUTER JOIN stateproducts c
              ON a.state_id = c.state_id AND 
                 b.product_id = c.product_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I simply cannot get this to work. I have some content that
Hey guys I am getting this exception when trying to run the query Column
Hey guys, hope this isn't too much of a n00b question I'm mainly a
Hey guys so in JQuery ui it produces a close link that once clicked
Hey guys, I have this quick bit of code that I can't figure out
Hey guys this is a followup to my previous question . I now have
Hey guys I have this page : PS: this is temp data, so it
hey guys i wanna ask a question about sending data to database to server
Hey guys this is a stored procedure that updates the PrevLoc field..but I want
Hey guys, I don't know if this question has been asked yet but imagine

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.