Turn a multi-line query into One Line Only with all records in MYSQL

Asked

Viewed 46 times

1

Someone with knowledge in MYSQL to help me in this case?

How to turn a query that generates multiple lines into a single line with all records next to each other in the Mysql database.

Example in the image below:

inserir a descrição da imagem aqui

  • 2

    Only one problem, Mysql only supports 4066 columns. Could explain why you want to do this?

  • You won’t make 50 columns. The purpose is that all these records are on the same line to insert into an array in php and then insert into an excel spreadsheet that the application will generate. I will replace each id with: First Row, Second Row, Third Row, Fourth Row.

  • 1

    I don’t think you can do what you want, even if you can, I don’t think it would be a good solution. Think about how to solve this with PHP and not with Mysql. I think it will be the best way.

  • 2

    that’s called Pivot Table, here in the OS a question with good examples of code: https://stackoverflow.com/questions/7674786/mysql-pivot-table

  • Take a look in that reply

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.