Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you remove duplicates from cross join This is my data.

Food Item Car CarNo

1 1 CarA Car1

1 2 CarB Car2

I want the data to be like this 1 1,2 Car A,CarB Car1,Car2
Posted
Comments
skydger 4-Feb-14 14:11pm    
What is the query do you use?
hushhush1 5-Feb-14 1:14am    
ALTER PROCEDURE Inventory
AS
BEGIN
INSERT INTO Inventory (FoodID, FoodName, ItemID, ItemName)
Select DISTINCT f.FoodID, f.FoodName, i.ItemID, I.Name from Food f CROSS JOIN Item i
WHERE f.FoodID=i.ItemID
END
skydger 5-Feb-14 1:37am    
Please provide us 'food' and 'item' tables structures or samples of data.
hushhush1 5-Feb-14 1:43am    
Food Item Inventory
FoodID ItemID FoodID, ItemID

Right now, there's duplicate in cross join.
hushhush1 5-Feb-14 1:51am    
Can you other joins or any methods?

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