我必须做
SELECT column1,column2
INTO OUTFILE 'out_1.csv'
FROM table1
WHERE column1.name = '1'
SELECT column1,column2
INTO OUTFILE 'out_2.csv'
FROM table1
WHERE column1.name = '2'
SELECT column1,column2
INTO OUTFILE 'out_3.csv'
FROM table1
WHERE column1.name = '3'
等等......我认为做这样的事情是个好主意:
SELECT column1,column2
INTO OUTFILE 'out_$1.csv'
FROM table1
WHERE column1.name = $1
并通过 UNIX shell 脚本传递参数 $1。但也许有更好的方法。有一种 SQL“本机”方法可以遍历 1 到 40 的范围吗?