I'd like to export some data from MySQL, but not the entire MySQL database. And I'd like the export to be human-readable SQL statements that can recreate the data (i.e. not just an XML or CSV dump).
So I'm looking for something like:
SELECT * FROM mytable WHERE id = 3 INTO OUTFILE 'test'
And I'd like the results to be standard SQL in a text file (which I can then run against a remote database). Ideally, I'd like to specify if it's an INSERT or UPDATE statement in the output file.
This functionality exists in phpMyAdmin but I'd like to have it in my own PHP script so I can automate things a bit. So, can MySQL do this on its own, or do I need to write my own code to manually piece together the export SQL statements?