我有一张表,需要拆分为许多 .csv 文件,每个文件都有一组基于其中一列内容的行。
我在这里找到了这个解决方案:Export Table Into Files Grouping By A Column,并且查询工作正常:
SELECT concat('SELECT * FROM YourTable WHERE col1 = ''',
col1, ''' INTO OUTFILE '''c:\result-', col1, '.txt'' ',
'FIELDS TERMINATED BY '','' OPTIONALLY ENCLOSED BY ''"''',
'LINES TERMINATED BY ''\n'';')
FROM YourTable
GROUP BY col1
但是,当我执行这个查询时,我得到一列字段,其中每个字段都有一个这样的选择语句:
SELECT * FROM table WHERE `col1` = 'value' INTO OUTFILE c:\results - value.csv FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ' "' LINES TERMINATED BY '\n';
我如何执行这些语句中的每一个?