Skip to content
Advertisement

mysql : check if column id is Consecutive [closed]

I have a table that contains IDs.

Number 5 and number 8 are not in the table. I want to select only those rows from the table

Advertisement

Answer

You can get the gaps by looking at the previous row. If your table is not too large:

Actually splitting this out into separate rows is tricky in earlier versions of MySQL unless you have a number or tally table.

If your data is large, you can use variables instead:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement