dimanche 2 novembre 2014

Transpose columns into rows in mysql


Vote count:

0




need help configuring the query below:


Query1:



SELECT @s:= @s + 1 serial_number,`COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`, (SELECT @s:= 0) AS s
WHERE `TABLE_SCHEMA`='2014rawfiles'
AND `TABLE_NAME`='012014actives';


Query1 output:



| serial_number | COLUMN_NAME |
| 1 | ID |
| 2 | FirstName |
| 3 | LastName |
... up to 89 rows ...


I am trying to transpose the output of this query to look like this:



| 1 | 2 | 3 |
| ID | FirstName | LastName |


with the serial_number as header and the COLUMN_NAME as a single row. Any ideas?


Thanks in advance!



asked 19 secs ago







Transpose columns into rows in mysql

Aucun commentaire:

Enregistrer un commentaire