I want to find missing values within range of a counter with gaps and then make sure the value displayed is within 1000 to 65000.
To get over 1000, I can modify How do I find a "gap" in running counter with SQL? but how do I make sure i pick a value under 65000? For reference the underlying table has a few 100 rows and will never have more than 10k rows, but the existing values are already in from 1 through 65000 (Randomly increasing numbers).
SELECT id + 1000
FROM mytable mo
WHERE NOT EXISTS
(
SELECT NULL
FROM mytable mi
WHERE mi.id = mo.id + 1000
)
ORDER BY
id
LIMIT 1