Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySQL obtient les ID manquants de la table

SELECT a.id+1 AS start, MIN(b.id) - 1 AS end
    FROM testtable AS a, testtable AS b
    WHERE a.id < b.id
    GROUP BY a.id
    HAVING start < MIN(b.id)

J'espère que ce lien vous aidera également /sequence-gaps-in-mysql/