MYSQL - Rows to Columns

Posted by Bob Rivers on Stack Overflow See other posts from Stack Overflow or by Bob Rivers
Published on 2009-08-06T20:22:49Z Indexed on 2010/03/31 16:33 UTC
Read the original article Hit count: 345

Hi,

I tried to search posts, but I only found solutions for SQL Server/Access. I need a solution to MYSQL (5.X).

I have a table with 3 columns: hostid, itemname, itemvalue. If I do a select, it will return

1  A  10
1  B  3
2  A  9
2  C  40

How do I query the database to return something like

   A    B    C
1  10   3
2  9         40

© Stack Overflow or respective owner

Related posts about mysql

Related posts about pivot-table