This question explains how to find the first "unused" number in a table, but how can I find the same so that I can define extra constraints. How do I alter the query so that I get the first unused number after that's greater than 100
e.g. If I have 23, 56, 100, 101, 103 in my table i should get 102.