How to select item matching Only IN List in sql server

后端 未结 4 656
春和景丽
春和景丽 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:42

    you could try something like this:

    SELECT id, Tag FROM (
    SELECT id, Tag, COUNT(*) OVER(partition by id) as cnt
    FROM pagetags
    WHERE Tag in(1,2,4)
    GROUP BY id, tag
    ) a WHERE a.cnt = 3
    

提交回复
热议问题