What I want now is the equivalent to select ONLY those PARTS where they have a Category of 12 AND 22 AND 33
Most compact and easiest bearing in mind that the select statement is built up dynamically based on a selection of Categories in a front end app with tick boxes.
Microsoft SQL ServerMicrosoft SQL Server 2008Databases
The relationship is that Each PART can have any number of Categories. The join table is PartsCategories
that has an Id, FKCategory and FKParts, respectively the Key of a category and a part.
So if I say I want Parts for Categories 12,22 and 33 then yes, all 3 rows must exist in PartsCategories for a Part to be included in the result set.
If i had Categories of 12 and 22 then of course all Parts with those two categories would be included.
Oh and of course the Categories and not Exclusive, a part can have other categories but those are not part of the select.
Hope thats clear?
Qlemo
Do you mean "exactly all of those categories" or "at least all of those categories"? So there may be more, but not less, then the given categories?
Neil Russell
ASKER
@Qlemo
Correct, there must be ALL of the ones in question but may be others.
So if a Part had categories of 1,5,7,12,22 and 33 it would still match 12,22,33 but NOT match 7,12,23
that has an Id, FKCategory and FKParts, respectively the Key of a category and a part.
So if I say I want Parts for Categories 12,22 and 33 then yes, all 3 rows must exist in PartsCategories for a Part to be included in the result set.
If i had Categories of 12 and 22 then of course all Parts with those two categories would be included.
Oh and of course the Categories and not Exclusive, a part can have other categories but those are not part of the select.
Hope thats clear?