How can I convert rows into columns in a MySQL query?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- SQL to Parse a Key-Value String
- Why sometimes there is one of more gap(s) in the v
You can turn rows into a column with
GROUP_CONCAT
, but you can't transpose whole result sets in any automatic way. You either write a query that produces each column manually, or you do it in an application.Here's a tutorial on writing the complicated queries to emulate the transposition:
http://www.artfulsoftware.com/infotree/queries.php#78