I've got a table I need to split into many .csv files with each file have a group of rows based on the contents of one of the columns.
I found this solution here: Export Table Into Files Grouping By A Column, and got the query working just fine:
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
However, when I execute this query, I get a single column of fields where each field has a select statement like this:
SELECT * FROM table WHERE `col1` = 'value' INTO OUTFILE c:\results - value.csv FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ' "' LINES TERMINATED BY '\n';
How do I execute each of those statements?