I'm trying to get all the numbers in a range where I have two integer columns in MySQL.
Here is an example of the structure:
+----+-------+------+
| id | a | b |
+----+-------+------+
| 1 | 1971 | 1975 |
| 2 | 1975 | 1975 |
| 3 | 1980 | 1982 |
+----+-------+------+
What I'd like is something like this:
SELECT id, RANGE(a,b) as range FROM table;
And the output should be like this:
+----+--------------------------+
| id | range |
+----+--------------------------+
| 1 | 1971 1972 1973 1974 1975 |
| 2 | 1975 |
| 3 | 1980 1981 1982 |
+----+--------------------------+
Also, the function needs to be have reasonable performance as there are 100,000+ rows in the table. I was initially doing something in PHP but it's proving to be way too slow to select and parse every single row. I haven't tried anything yet since I am completely stumped about how to do something like in SQL.
Also, I did look at this question but it's a different enough case that I couldn't figure out how to apply the solutions provided.