ALTER TABLE `table1` MODIFY `id` INT(11);
ALTER TABLE `table1` DROP PRIMARY KEY;
UPDATE `table1` SET `id`='0';
ALTER TABLE `table1` AUTO_INCREMENT=1;
ALTER TABLE `table1` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY;
SELECT
MIN(d.number + 1) AS number
FROM
data AS d
WHERE (
SELECT MIN(1) FROM data AS st WHERE st.number = (d.number + 1)
) IS NULL
ORDER BY d.number ASC
LIMIT 1