In mysql database table I have integer field, what i want to find missing minimum value of the sequence.
Please Help.
1,2,3,5,6,8,....
missing is 4
In mysql database table I have integer field, what i want to find missing minimum value of the sequence.
Please Help.
1,2,3,5,6,8,....
missing is 4
You can do something like this:
SELECT val + 1
FROM mytable t1
WHERE NOT EXISTS
(SELECT NULL FROM mytable t2 WHERE t2.val = t1.val + 1)
ORDER BY val
LIMIT 1