MySQL pivot tables - covert rows to columns
- by user2723490
This is the structure of my table:
Then I run a query
SELECT `date`,`index_name`,`results` FROM `mst_ind` WHERE `index_name` IN ('MSCI EAFE Mid NR USD', 'Alerian MLP PR USD') AND `time_period`='M1'
and get a table like
How can I convert "index_name" rows to columns like:
date | MSCI EAFE Mid NR USD | Alerian MLP PR USD etc
In other…