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

后端 未结 4 1641
庸人自扰
庸人自扰 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 09:59

    create table B (id int)
    insert into B values (10),(11),(12),(13),(14)
    
    select *
    from B
    left join A 
    on A.id=B.id
    where A.id is null
    
    drop table B
    

    http://sqlfiddle.com/#!6/6666c1/30

提交回复
热议问题