sqlite - How to find a gap in range in SQL -
this question explains how find first "unused" number in table, how can find same can define constraints. how alter query first unused number after that's greater 100
e.g. if have 23, 56, 100, 101, 103 in table should 102.
in mysql , postgresql
select id + 1 test mo not exists ( select null test mi mi.id = mo.id + 1 ) , mo.id> 100 order id limit 1
fiddle mysql , fiddle postgresql
in ms sql
select top 1 id + 1 test mo not exists ( select null test mi mi.id = mo.id + 1 ) , mo.id > 100 order id
Comments
Post a Comment