Possible Duplicate:
MySQL pivot table
Should I be using a LEFT JOIN using derived tables, a RIGHT JOIN using derived tables, a different table design, or do I need to query the table and write Python code to produce the desired output shown below?
The output I would like to get to would yield the following output example:
==========================
| 2005 | 2006 | 2007 | <--- These headings are not necessary
==========================
| A | A | A |
--------------------------
| AA | AA | AA |
--------------------------
| BB | BB | |
--------------------------
| C | | C |
--------------------------
The data for the query is in a two column table containing (symbol, year):
====================
| Symbol | Year |
====================
| A | 2005 |
--------------------
| AA | 2005 |
--------------------
| BB | 2005 |
--------------------
| C | 2005 |
--------------------
| A | 2006 |
--------------------
| AA | 2006 |
--------------------
| BB | 2006 |
--------------------
| A | 2007 |
--------------------
| AA | 2007 |
--------------------
| C | 2007 |
--------------------