MySQL export query as insert statements
You might be able to use mysqldump
instead. Check out the parameters --tables
and --where=
.
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
If you have MySQL Workbench it can generate insert statements for you.
In the SQL editor run your query, then from the result set you can click the export button. Then in the "Save as Type" select as "SQL INSERT statements (*.sql)". Click Save, confirm the table you are exporting and click ok.
If you open the file you should see your result set as insert statements with the column names.
I only tested this on a simple select * from table. I haven't tested this with multiple tables. I hope this helps.
EDIT: Seems like workbench is available for Windows, OSX, and Linux (Thanks vcardillo)