Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table `tableid` (`id` int);
- insert into `tableid` (`id`) values
- (1),(2),(3),(4),(5), (7),(8),(9),(10),(11),(12), (14);
- select
- R.`number`
- from
- (
- select 1000*t4.n + 100*t3.n + 10*t1.n + t2.n + 1 as `number`
- from
- (
- (select 0 n union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9 ) t1
- cross join
- (select 0 n union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9 ) t2
- cross join
- (select 0 n union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9) t3
- cross join
- (select 0 n union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9) t4
- )
- ) R
- left outer join `tableid` t on t.`id` = R.`number`
- where
- R.`number` <2501
- and t.`id` is null
- order by `number`
- SELECT seq FROM seq_1_to_2501
- left join yourtable on seq=youridcol
- where seq is null
- SELECT seq FROM seq_1_to_2501
- left join yourtable on seq=youridcol
- where seq is null
Add Comment
Please, Sign In to add comment