0

I have a Mysql and PHP driven website, I want to output some data form a mysql database to an excel file.

I have a question about fetching the data I want and getting it into the file correctly.

Here is an example of my table:

||id|locationID|itemID|groupID|qty||
------------------------------------
||0 | 1        | 1    | 1     |2  ||
||1 | 2        | 1    | 1     |12 ||
||3 | 2        | 3    | 1     |1  ||
||4 | 1        | 3    | 1     |5  ||

What I want to do is output the data like this in to a spreadsheet:

Item | Location 1 QTY | Location 2 QTY
--------------------------------------
1    |          2     |   12
3    |          5     |   1

Is this possible?

  • 3
    Possible duplicate of [MySQL pivot table](https://stackoverflow.com/questions/7674786/mysql-pivot-table) – mx0 Jul 07 '17 at 17:28
  • This is probably exactly what I want to do.. Im just a bit confused as to how this actually works.. is there a way you could give me an example SQL query using the above table? – Stephen Redding Jul 09 '17 at 20:09

0 Answers0