How to select item matching Only IN List in sql server

后端 未结 4 672
春和景丽
春和景丽 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 17:00

    SELECT distinct(PageID)
    FROM   pagetags
    WHERE  TagID IN (1,2,4)
    and PageID in
    (select distinct(PageID) from pagetags group by PageID having count(TagID)=3)
    group by PageID
    

提交回复
热议问题