This question has already been answered:
- How to choose the missing ID? 7 answers
Imagine that there is a certain table Users
, in which there is an identifier (primary key) with the name id
. But for some reason, the id
string was ripped out. And it turned out such a table:
id 1,2,3,5,6,7,8,10,12
The question is how to get using only one select set, which includes only the missing numbers. So what is the sql query to do?
Asked the question at the interview, it became very interesting.