I'm new to MySQL. I have a datatable and I'll like to convert it to a row of 5.
From SELECT File FROM tbl_file
. I have
+--------+
| File |
+--------+
| B.jpg |
+--------+
| X.jpg |
+--------+
| H.png |
+--------+
| C.png |
+--------+
| A.gif |
+--------+
| G.pdf |
+--------+
| Y.docx |
+--------+
| U.jpeg |
+--------+
Here's what I need when the rows are rotated to 5 columns.
+-------+--------+--------+-------+-------+
| A | B | C | D | E |
+-------+--------+--------+-------+-------+
| B.jpg | X.jpg | H.png | C.png | A.gif |
+-------+--------+--------+-------+-------+
| G.pdf | Y.docx | U.jpeg | | |
+-------+--------+--------+-------+-------+
When the first row is filled to it's limit which is 5, then the next row continues to be filled.
This is what I've tried:
SELECT GROUP_CONCAT(File) FROM tbl_file GROUP BY id;
I'm not getting what I intended to get.
Thanks a lot.