troubleshooting Question

SQL Query using OR now want AND alternative.

Avatar of Neil Russell
Neil RussellFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerMicrosoft SQL Server 2008Databases
11 Comments3 Solutions58 ViewsLast Modified:
I have the following SQL query that works just fine where I want all PARTS that have ANY of the selected Categories.

SELECT  DISTINCT * from PARTS where Id in (Select FKPARTS from PartsCategories WHERE FKCategory in (12,22,33))

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.
Join our community to see this answer!
Unlock 3 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros