I have 3 tables that are connected - car, part, and carpart.
car has models of cars, part has parts for different cars, and carpart uses carID and partID to connect parts and cars (for instance 1 type of treansmission belongs to only bmw's).
When a car model is selected, its carID should be used to select all the parts made available for that car, meaning use carpart to display data from part (price, type etc)
How is this done?
I kind of forgot sql but I guess the sql statement would be something like
select * from part where ID in any (select partID from carpart where modelID = wantedModel )
cdf
Member
31 Points
61 Posts
lambda expression
May 06, 2012 01:23 AM|LINK
I have 3 tables that are connected - car, part, and carpart.
car has models of cars, part has parts for different cars, and carpart uses carID and partID to connect parts and cars (for instance 1 type of treansmission belongs to only bmw's).
When a car model is selected, its carID should be used to select all the parts made available for that car, meaning use carpart to display data from part (price, type etc)
How is this done?
I kind of forgot sql but I guess the sql statement would be something like
select * from part where ID in any (select partID from carpart where modelID = wantedModel )
Bhaarat
Contributor
3433 Points
855 Posts
Re: lambda expression
May 06, 2012 02:03 AM|LINK
yes query is almost right.. just remove "any"
select * from part where ID in (select partID from carpart where modelID = @wantedModel )
here @wantedModel is variable which will contain the ID for modelID.
if you are using LINQ
var objResult = (from obj in CarParts
where obj.ModeID == WantedModelID
select obj.Parts) .toList();
here WantedModelID is variable for ModelID
all the best
Remember to click "Mark as Answer" on the post that helps U
http://ransandeep.blogspot.com