2
--------------------
- # - timesheet_id -
--------------------
- 1 -      1       -
--------------------
- 2 -      2       -
--------------------

Now the format required should be in "1,2" which is nothing but the values of timesheet_id. Somebody please help.

4

2 回答 2

5
SELECT GROUP_CONCAT(timesheet_ID) as TimeList
FROM   tableName
INTO   OUTFILE '/tmp/timeIDList.csv'  -- file output path
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

资源

于 2013-02-28T04:44:54.230 回答
1

在 mySQL 中,您可以使用 GROUP_CONCAT

SELECT GROUP_CONCAT(timesheet_id SEPARATOR ',') FROM table
于 2013-02-28T04:49:23.193 回答