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);
谢谢学习!
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);
谢谢学习!