title: MYSQL INSERT SELECT STATEMENT - ERROR 1292
body: <p>I have run a select statement with the information I need, the select statement works fine and collects all the data I need which is to find the most common month, year, and time of day of accidents in recent years from the main table in my database road_safety. My next step is to insert this selected data into a temporary table and export the data to a CSV file. However I am having trouble using this select statement to insert into the temporary table. I assume the error is referring to my ON clause but I cant see where the problem is.
  Below is my select statement which works fine.</p>
  
  <pre><code>    SELECT t2.accident_time, COUNT(r1.time_id) AS time_count, r1.accident_year, r1.accident_month
      FROM road_safety r1
      LEFT OUTER JOIN accident_time t2 ON t2.accident_time = r1.time_id
      GROUP BY r1.time_id, r1.accident_year, r1.accident_month, t2.accident_time
      ORDER BY time_count DESC
      LIMIT 1;
  </code></pre>
  
  <p>and here is the insert statement</p>
  
  <pre><code>    CREATE TEMPORARY TABLE temp1
      (
      accident_time_t VARCHAR(50) DEFAULT NULL,
      count_t INT DEFAULT NULL,
      accident_year_t VARCHAR(50) DEFAULT NULL,
      accident_month_t VARCHAR(50) DEFAULT NULL);
  
      INSERT INTO temp1
      (accident_time_t, count_t, accident_year_t, accident_month_t)
      SELECT t2.accident_time, COUNT(r1.time_id) AS time_count, r1.accident_year, r1.accident_month
      FROM road_safety r1
      LEFT OUTER JOIN accident_time t2 ON t2.accident_time = r1.time_id
      GROUP BY r1.time_id, r1.accident_year, r1.accident_month, t2.accident_time
      ORDER BY time_count DESC
      LIMIT 1;
  </code></pre>
  
  <p>and here is the error code which is referring to the piece of data from t2.accident_time </p>
  
  <pre><code>    Error Code: 1292. Truncated incorrect DOUBLE value: '12am-4am'  0.000 sec
  </code></pre>