I have two tables, Data(Name, dataID)
and Attributes(Name, attributeID, dataID)
with a one-to-many relationship. One dataID
might be associated with many attributeID
's.
What I want to do is run a query that finds all dataIDs that have a specific set of attributeIDs. I can't do:
SELECT dataID
FROM Attributes
WHERE dataID = 1 AND (attributeID = 1 OR attributeID = 2 OR attributeID = 3);
That would grab all dataID's with any one of those attributes, I want the dataID's that have all of those attributes.
Suggestions?
Still wrapping my head around queries using more than very basic selects.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…