Dear all, i want to show some data in one row from 1 column and also 开发者_Go百科separated by comma.
if I do the regular SELECT
method, it must be show as the long rows.
SELECT Serial_number FROM data
+-------------+
|Serial_number|
+-------------+
|0001 |
|0002 |
|0003 |
+-------------+ //and so on
How do i do to show result as:
+------------------------------+
|Serial_number |
+------------------------------+
|0001,0002,0003,....and so on |
+------------------------------+
thanks for advance.
You can use GROUP_CONCAT
SELECT GROUP_CONCAT(Serial_number ) FROM data;
Note: GROUP_CONCAT has a maximum length.
select concat(col1, ',' , col2, .....) from tbl;
i think you can use something like phpmyadmin and save a select statement to file, then select csv as the file type..
what you want is GROUP_CONCAT()
SELECT GROUP_CONCAT(Serial_number) FROM data
yields:
0001,0002,0003,...
精彩评论