我有一個MySQL數據庫,看起來像這樣:MySQL的單元格值的日期作爲新列具有多年
|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 |
但我想有一個看起來像這樣
|city | 2009 | 2010 | 2011 | 2012 |
|city1 | 1 | 0 | 1 | 1 |
|city2 | 0 | 1 | 1 | 1 |
|city3 | 1 | 1 | 0 | 1 |
SELECT COUNT(ID)AS GROUP BY城市 我有問題要分開年不同列的要求,城市,YEAR(創建)截至今年 FROM查詢。我實際上不知道該怎麼做 – jocken 2012-04-03 07:44:54