Create an inline SQL table on the fly (for an excluding left join)

后端 未结 4 1637
庸人自扰
庸人自扰 2020-12-13 09:26

Let\'s assume the following:

Table A

id | value
----------
1   | red
2   | orange
5   | yellow
10  | green
11  | blue
12  | indigo
20  | violet
         


        
4条回答
  •  被撕碎了的回忆
    2020-12-13 10:02

    You can create an "inline table" with a UNION subquery:

    (
                SELECT 10 AS id
      UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14
      -- etc.
    ) AS inline_table
    

提交回复
热议问题