Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table of 2 columns for my Customer table and 3 columns for my Item table. They have no common columns. How do I join them where there's a condition set to it too? i need to implement a table of all the customer details whose price > 200 but i keep getting duplicates :(

something like this

Customer_id Customer_Name price
1002 Amp 250
1166 Boo 1000

What I have tried:

SELECT cust_id, cust_name, price FROM Customer FULL JOIN Item WHERE Item.price > 200
Posted
Updated 30-May-20 23:22pm
v2
Comments
[no name] 31-May-20 5:34am    
I assume the "three field table" you show in the question is the "customer_item" table.
Now show also the two fields of your customer table.

1 solution

You cannot join two tables if they are not related to each other.
You should have a table between Customer and Item tables, which would for example record the items bought by your customers. For now, both tables are completely unrelated, so there is no way to join them in a sensible way.
Moreover, what does mean the price of a customer? Do you mean the total sum of bought items prices by that customer? In that case, you definitely need a table between Cutomer and Item. This is called a many-to-many relationship, and you cannot model it with only two tables.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900