Ai
1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc-1613.test 730 Bytes
一键复制 编辑 原始数据 按行查看 历史
逸扬 提交于 2022-04-27 00:22 +08:00 . 1532-1596-1613-1709-1767-1831-1949-1951-1972 (9)
# $1613. 找到遗失的ID
# https://leetcode-cn.com/problems/find-the-missing-ids/
# SQL架构
Create table If Not Exists Customers (customer_id int, customer_name varchar(20));
Truncate table Customers;
insert into Customers (customer_id, customer_name) values ('1', 'Alice');
insert into Customers (customer_id, customer_name) values ('4', 'Bob');
insert into Customers (customer_id, customer_name) values ('5', 'Charlie');
# Write your MySQL query statement below
with recursive tmp as (
select 1 as n union all
select n + 1 from tmp where n <= 100 )
select n as ids from tmp
where n not in ( select customer_id from Customers )
and n <=( select max(customer_id) from Customers );
# clean-up
drop table Customers;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

搜索帮助