How to export mysql query result so I can import it back again
<p>I want to dump data from my table by certain criteria, here is the sql query:</p>

<p><code>"SELECT * FROM document WHERE date BETWEEN 20160101 AND 20160131"</code></p>

<p>Table that I am selecting from is MyISAM Merge.</p>

<p>I have deleted rows that are matching that query, and I want to import them back from backup, but only those rows.</p>

<p>I have tried making dump like this: </p>

<p><code>mysql -uroot -proot mydb -e "SELECT * INTO OUTFILE '/tmp/doc.sql' from document WHERE date BETWEEN 20160101 AND 20160131".</code></p>

<p>But it will generate a file that can not be imported by phpmyadmin import tool. And yet again PMA does not want to do any export of this query result.</p>

<p>Any help ? I can not post structure of the real database/table because of NDA.</p>

<p>EDIT: for all that are having trouble dumping data from MyISAM MRG table, you need to dump from the subtable, not the main one.</p>