title: How to export some rows of a MySQL table from a WHERE clause?
body: <p>How to export some rows of a MySQL table with where clause from a PHP script?</p>
  <p>I have a MySQL say test and I want to create a importable .sql file for rows where id are between 10 and 100, using PHP script.</p>
  <p>I want to create a sql file say test.sql which can be imported to MySQL database.</p>
  <p>Mycode:</p>
  <pre><code>$con=mysqli_connect(&quot;localhost&quot;, &quot;root&quot;,&quot;&quot;,&quot;mydatabase&quot;);
  
  $tableName  = 'test';
  $backupFile = '/opt/lampp/htdocs/practices/phpTest/test.sql';
  $query      = &quot;SELECT * INTO OUTFILE '$backupFile' FROM $tableName WHERE id BETWEEN 10 AND 500&quot;;
  
  $result = mysqli_query($con,$query);
  </code></pre>
  <p>This creates a test.sql file, but when I try to import, it gives error #1064.<br />
  My script only creates a file with rows with columns name and table sturcute or insert query.</p>