I have a table where I have a row id that is my primary key. It is a table with ~250 thousand rows. Usually, the id should be a sequential number. Now I want to find out, if there is a number missing in the sequence of numbers.
Example: The table contains the ids
1, 2, 4, 6, 7, 8, 9, 10 That means, in the sequence of numbers from 1 to 10, the numbers 3 and 5 are missing.
How would a MySQL query look like that only returns the missing ids? Is there a way to increment a counter and compare if that id exists?
COUNT(*)withMAX(id); that's assuming you don't have master-master replication.ids to check if all "parent items" are being analyzed.ids, but I like this approach. Nice and easy!COUNT(*) <> MAX(id).