How to select non-consecutive rows in MySQL?

mysql, select

Solution

SELECT *
FROM your_table AS a
    LEFT JOIN your_table AS b
        ON a.key_column = b.key_column - 1
WHERE b.key_column IS NULL

Problem

If the primary keys of the records are `1,3,4,5,6,8` I want to select the records with pk:`1,6` NOTE I don't know which ids are non-consecutive

Original source