0

I have a mysql tableA, it changes it's fieldname every minute,i need it's fieldname, so i do like this:

select COLUMN_NAME from information_schema.COLUMNS where table_name = 'tableA';

output:
+-------------+
| COLUMN_NAME |
+-------------+
| min         |
| unkonwn1    |
| unkonwn2    |
| unkonwn3    |
| unkonwn4    |
| unkonwn5    |
| average     |
+-------------+

but i need select output like this:

+-------+----------+----------+---------+------------+---------+---------+
|  min  | unkonwn1 | unkonwn2 | unkonwn3| unkonwn4   | unkonwn5| average |
+-------+----------+----------+---------+------------+---------+---------+

how to get this kind of result ?

61938388
  • 53
  • 6
  • Check this out https://ubiq.co/database-blog/transpose-rows-columns-dynamically-mysql/ – Simon Martinelli Apr 03 '21 at 08:51
  • do a search on stakoverflow, like [mysql rows to columns](https://stackoverflow.com/search?q=mysql+rows+to+columns), and find: [MySQL - Rows to Columns](https://stackoverflow.com/questions/1241178/mysql-rows-to-columns) – Luuk Apr 03 '21 at 09:00
  • It’s easy for veterans, but it’s hard for a novice like me to understand – 61938388 Apr 03 '21 at 09:23
  • and it's column to row, not row to column – 61938388 Apr 03 '21 at 09:29

0 Answers0