Guest User

Untitled

a guest
Jul 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. create table `tableid` (`id` int);
  2.  
  3. insert into `tableid` (`id`) values
  4. (1),(2),(3),(4),(5), (7),(8),(9),(10),(11),(12), (14);
  5.  
  6. select
  7. R.`number`
  8. from
  9.  
  10. (
  11. select 1000*t4.n + 100*t3.n + 10*t1.n + t2.n + 1 as `number`
  12. from
  13. (
  14. (select 0 n union select 1 union select 2 union select 3 union select 4
  15. union select 5 union select 6 union select 7 union select 8 union select 9 ) t1
  16. cross join
  17. (select 0 n union select 1 union select 2 union select 3 union select 4
  18. union select 5 union select 6 union select 7 union select 8 union select 9 ) t2
  19. cross join
  20. (select 0 n union select 1 union select 2 union select 3 union select 4
  21. union select 5 union select 6 union select 7 union select 8 union select 9) t3
  22. cross join
  23. (select 0 n union select 1 union select 2 union select 3 union select 4
  24. union select 5 union select 6 union select 7 union select 8 union select 9) t4
  25. )
  26. ) R
  27.  
  28. left outer join `tableid` t on t.`id` = R.`number`
  29. where
  30. R.`number` <2501
  31. and t.`id` is null
  32. order by `number`
  33.  
  34. SELECT seq FROM seq_1_to_2501
  35. left join yourtable on seq=youridcol
  36. where seq is null
  37.  
  38. SELECT seq FROM seq_1_to_2501
  39. left join yourtable on seq=youridcol
  40. where seq is null
Add Comment
Please, Sign In to add comment