SQL-查询自增id里面被删除的id数据

SQL-查询自增id里面被删除的id数据
 
1. 直接展示sql
SELECT t1.id + 1 AS missing_id
FROM test_table t1
WHERE NOT EXISTS (
    SELECT * FROM test_table t2 WHERE t2.id = t1.id + 1
) AND t1.id < (SELECT MAX(id) FROM test_table);

谢谢学习!

posted @ 2023-08-30 18:26  锦大大的博客呀!  阅读(107)  评论(0编辑  收藏  举报