title: How to import XML file into MySQL database table using XML_LOAD(); function
body: <p>I have an XML file which looks like this : </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;resultset statement="YOUR SQL STATEMENTS TO GENERATE THIS XML FILE" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;row&gt;
      &lt;field name="personal_number"&gt;539&lt;/field&gt;
      &lt;field name="firstname"&gt;Name&lt;/field&gt;
      &lt;field name="lastname"&gt;Surname&lt;/field&gt;
      &lt;field name="email"&gt;email.domain.com&lt;/field&gt;
      &lt;field name="start_time"&gt;2011-04-02 13:30:00&lt;/field&gt;
      &lt;field name="end_time"&gt;2011-04-02 18:15:00&lt;/field&gt;
      &lt;field name="employee_category"&gt;1,2,4,5,22,37,38,39,41,43,44&lt;/field&gt;
    &lt;/row&gt;
    &lt;row&gt;
      &lt;field name="personal_number"&gt;539&lt;/field&gt;
      &lt;field name="firstname"&gt;Name&lt;/field&gt;
      &lt;field name="lastname"&gt;Surname&lt;/field&gt;
      &lt;field name="email"&gt;email.domain.com&lt;/field&gt;
      &lt;field name="start_time"&gt;2011-04-02 13:30:00&lt;/field&gt;
      &lt;field name="end_time"&gt;2011-04-02 18:15:00&lt;/field&gt;
      &lt;field name="employee_category"&gt;1,2,4,5,22,37,38,39,41,43,44&lt;/field&gt;
    &lt;/row&gt;
    &lt;row&gt;
      &lt;field name="personal_number"&gt;539&lt;/field&gt;
      &lt;field name="firstname"&gt;Name&lt;/field&gt;
      &lt;field name="lastname"&gt;Surname&lt;/field&gt;
      &lt;field name="email"&gt;email.domain.com&lt;/field&gt;
      &lt;field name="start_time"&gt;2011-04-02 13:30:00&lt;/field&gt;
      &lt;field name="end_time"&gt;2011-04-02 18:15:00&lt;/field&gt;
      &lt;field name="employee_category"&gt;1,2,4,5,22,37,38,39,41,43,44&lt;/field&gt;
    &lt;/row&gt;
  </code></pre>
  
  <p></p>
  
  <p>I am trying to import it in MySQL using SQL statement : </p>
  
  <pre><code>use databasename;
  LOAD XML LOCAL INFILE '/pathtofile/file.xml' INTO TABLE my_tablename;
  </code></pre>
  
  <p>The table my_tablename has the following fields : </p>
  
  <pre><code>id (auto increment id)
  personal_number(varchar)
  firstname(varchar) 
  lastname(varchar)
  email(varchar) 
  start_time(varchar)
  end_time(varchar)
  employee_category(varchar)
  </code></pre>
  
  <p>I get error : 
  Error Code: 1136
  Column count doesn't match value count at row 1</p>
  
  <p>I am using MySQL 5.1.56</p>
  
  <p>I assume this error occurs because the database table has field id, which is not present in the XML file. How is it possible to import this XML file using MySQL queries of built in functions such that it skips id column during the import and relies on the auto increment function for the id column?
  Is there some smarter way of handling XML file imports im MySQL?
  Maybe there is better statement which allows to specify column mapping?</p>
  
  <p>Thank you!</p>