I am working on an updated internal website that will pull data from a sql server. The data is automatically inserted into the database from a VAX system. The raw database looks like this:
mysql> SELECT * FROM userdb.clientdata WHERE datadate = '2016-09-23' AND header IN (1,3,6,9,212,2048);
+--------+--------------+-------------+----------+--------+-----------+-------------------------+---------------+---------------+
| id | clientnumber | plantnumber | datahour | header | datavalue | datadate | projectnumber | dec_precision |
+--------+--------------+-------------+----------+--------+-----------+-------------------------+---------------+---------------+
| 28673 | NULL | 2 | 1 | 1 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 28675 | NULL | 2 | 1 | 3 | 78.368 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 28678 | NULL | 2 | 1 | 6 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 28681 | NULL | 2 | 1 | 9 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 28884 | NULL | 2 | 1 | 212 | 0 | 2016-09-23 00:00:00.000 | NULL | 0 |
| 30720 | NULL | 2 | 1 | 2048 | 0 | 2016-09-23 00:00:00.000 | NULL | 0 |
| 30721 | NULL | 2 | 2 | 1 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 30723 | NULL | 2 | 2 | 3 | 77.342 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 30726 | NULL | 2 | 2 | 6 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 30729 | NULL | 2 | 2 | 9 | -5865.97 | 2016-09-23 00:00:00.000 | NULL | 1 |
| 30932 | NULL | 2 | 2 | 212 | 0 | 2016-09-23 00:00:00.000 | NULL | 0 |
| 32768 | NULL | 2 | 2 | 2048 | 0 | 2016-09-23 00:00:00.000 | NULL | 0 |
I need to be able to format it so the result looks like this:
+-------------------------+----------+---------+---------+---------+---------+-----------+------------+
| datadate | datahour | header1 | header3 | header6 | header9 | header212 | header2048 |
+-------------------------+----------+---------+---------+---------+---------+-----------+------------+
| 2016-09-23 00:00:00.000 | 1 | -5865.97| 78.368 | -5865.97| -5865.97| 0 | 0 |
| 2016-09-23 00:00:00.000 | 2 | -5865.97| 77.342 | -5865.97| -5865.97| 0 | 0 |
Any assistance would be appreciated.
MySQL 5.7.21 for Linux
Edit: The website will be using php, but I am looking for the actual MySQL Query to provide the result listed so I can store it in another table.