Using tuples in SQL “IN” clause

前端 未结 8 1111
刺人心
刺人心 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:51

    Here is another tuple solution using a join:

    SELECT 
      *
    FROM mytable m
    JOIN
    (
       SELECT "1234-567" group_id, 2 group_type 
       UNION ALL SELECT "4321-765", 3 
       UNION ALL SELECT "1111-222", 5
    ) [t]
    ON m.group_id = t.group_id 
    AND m.group_type = t.group_type
    

提交回复
热议问题