Using tuples in SQL “IN” clause

前端 未结 8 1100
刺人心
刺人心 2020-11-28 04:30

I have a table containing the fields group_id and group_type and I want to query the table for all the records having any tuple (group id, group type) from

8条回答
  •  温柔的废话
    2020-11-28 04:57

    In SQL Server 2008 you can do like this:

    select *
    from mytable as T
    where exists (select *
                  from (values ('1234-567', 2), 
                               ('4321-765', 3), 
                               ('1111-222', 5)) as V(group_id, group_type)
                  where T.group_id = V.group_id and
                        T.group_type = V.group_type               
                 )
    

提交回复
热议问题