--------------------
- # - timesheet_id -
--------------------
- 1 - 1 -
--------------------
- 2 - 2 -
--------------------
现在所需的格式应该是“1,2”,这只是timesheet_id的值。 有人请帮忙。
答案 0 :(得分: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'
SOURCE
答案 1 :(得分:1)
在mySQL中,你可以使用GROUP_CONCAT
SELECT GROUP_CONCAT(timesheet_id SEPARATOR ',') FROM table