Suppose I have a \"tags\" table with two columns: tagid and contentid. Each row represents a tag assigned to a piece of content. I want a
I don't know if this is better but it might be more maintainable
select contentid from tags where tagid = 334
intersect
select contentid from tags where tagid = 338
intersect
select contentid from tags where tagid = 342
You'd have to build it dynamically which wouldn't be as bad as your original solution.