I have a mysql database that looks like this:
|id | city | created |
|1 | city1 |2011-12-10 |
|2 | city2 |2010-02-01 |
|3 | city3 |2009-12-03 |
|4 | city1 |2012-11-16 |
|5 | city2 |2012-08-03 |
|6 | city3 |2011-10-01 |
|7 | city1 |2009-10-02 |
|8 | city2 |2011-12-01 |
|9 | city3 |2012-06-30 |
But I want to have an alternate table or view that looks like this
|city | 2009 | 2010 | 2011 | 2012 |
|city1 | 1 | 0 | 1 | 1 |
|city2 | 0 | 1 | 1 | 1 |
|city3 | 1 | 1 | 0 | 1 |
Maybe something like this: