Having a table with sequence numbers like
Table sequence_numbers
number
1
2
..
100
you can extract the numbers from your list using a JOIN and FIND_IN_SET() function:
select t.ID, s.number
from mytable t
join sequence_numbers s
on find_in_set(s.number, t.NUMBERS)
Result:
| ID | number |
|----|--------|
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
| 1 | 6 |
| 2 | 6 |
| 1 | 7 |
| 2 | 7 |
| 1 | 8 |
| 2 | 8 |
| 2 | 9 |
| 2 | 10 |
| 2 | 11 |
http://sqlfiddle.com/#!9/b4144/4
Now many tasks are much simpler with that result.
Limit to numbers from 3 to 7:
select t.ID, s.number
from mytable t
join sequence_numbers s
on find_in_set(s.number, t.NUMBERS)
where s.number between 3 and 7
Result:
| ID | number |
|----|--------|
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
| 1 | 6 |
| 2 | 6 |
| 1 | 7 |
| 2 | 7 |
http://sqlfiddle.com/#!9/b4144/3
A simple way to create a big sequence table is to use the internal columns
table (or any table with enough rows) joining it with itself:
create table sequence_numbers (number int auto_increment primary key)
select null as number
from information_schema.columns c1
cross join information_schema.columns c2
limit 1000000
;
http://sqlfiddle.com/#!9/7cc0a/2