I am looking for something like this but can\'t figure out the best way to write the query:
SELECT DISTINCT CategoryID FROM tbl_Categories c INNER JOIN
ma
-- Parameter string
declare @ParamStr varchar(100) = '234,245,645'
-- Convert param to xml
declare @XMLStr xml = convert(xml, ''+replace(@ParamStr, ',', ' ')+' ')
-- Store param values in table variable
declare @T table (ID int)
insert into @T
select r.value('.', 'int')
from @XMLStr.nodes('r') r(r)
-- Get the number of parameters
declare @ParamCount int = (select count(*) from @T)
-- Get the categoryids
select CategoryID
from mappingTable
where SubCategoryID in (select id from @T)
group by CategoryID
having count(CategoryID) = @ParamCount