How to select item matching Only IN List in sql server

后端 未结 4 655
春和景丽
春和景丽 2020-12-28 16:23

How can one select only the items he want in the IN list? for example

select * from pagetags where TagID in (1,2,4)

Now I want all the page

4条回答
  •  一整个雨季
    2020-12-28 16:49

    The term for this type of problem is relational division. One way below.

    SELECT PageID
    FROM   pagetags
    WHERE  TagID IN ( 1, 2, 4 )
    GROUP  BY PageID
    HAVING Count(DISTINCT TagID) = 3
    

提交回复
热议问题