I have this table named people
with two dates on MySQL:
| Name | start_date | end_date |
| John | 2007-03-01 | 2009-10-12 |
| Mike | 2001-06-06 | 2010-12-01 |
I want to create a view that lets me search by activity year, being activity year any year between the start_date
and the end_date
. So, I'd like to get a field with a sequence of years, like this:
| Name | activity_years |
| John | 2007,2008,2009 |
| Mike | 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 |
I've tried some approaches, but I can't get it. Since I want to create a view, I have to do it everything inside a SELECT statement and that is giving me some headache.