你的意思是这样吗:
SET @row_number = 0;
SELECT DATE_ADD(DATE_ADD(ActiveFrom, INTERVAL -1 DAY), INTERVAL x.D DAY) AS ActivityPeriods
FROM test
LEFT JOIN(SELECT *, (@row_number:=@row_number + 1) AS D FROM information_schema.COLUMNS) AS x ON x.D <= DATEDIFF(ActiveTo,ActiveFrom) +1
WHERE
ProjID = 20
ORDER BY ActivityPeriods
这将给你:
| ActivityPeriods |
| --------------- |
| 2018-01-01 |
| 2018-01-02 |
| 2018-01-03 |
| 2018-01-04 |
| 2018-02-05 |
| 2018-02-06 |
| 2018-02-07 |
| 2018-02-20 |
| 2018-02-21 |
| 2018-02-22 |
Fiddle Demo