Tuesday, January 1, 2013

Find Missing Sequence in mysql

Although this solution is for small numbers .

Sometime it happens that some sequence number miss and you need to find out the missing sequence to do that  first create a table with name of sequence and with one column name id and insert the numbers in my case i have number from 1-25 .

So now i have one table with name sequence which has column id and value 1-25 .

Now to find missing number of other table use this query  ;

select id from sequence where id not in (select id from other_table) ;

Thats it .