描述

image.png

题解

生成序列表

  1. with recursive t1 as
  2. (select 1 as ids
  3. union all
  4. select ids+1 from t1
  5. where ids<(select max(customer_id) from Customers))

用序列表与骨科表外连接筛选出剩余的id

  1. select t1.ids
  2. from t1 left join Customers as a on t1.ids=a.customer_id
  3. where a.customer_name is null;

写一起

  1. with recursive t1 as
  2. (select 1 as ids
  3. union all
  4. select ids+1 from t1
  5. where ids<(select max(customer_id) from Customers))
  6. select t1.ids
  7. from t1 left join Customers as a on t1.ids=a.customer_id
  8. where a.customer_name is null;