title: MySQL phpMyAdmin average value counting event for current datetime
body: <p>I have such a query about MySQL, which I am not fully familiar with, but I have to solve one problem. I have two tables, ie stats where I put my data (temperature, humidity) from the weather station and the avg_temp table, where I always need to save the average of the values obtained in stats for the given day. So I need to create an event in phpMyAdmin in a way that starts everyday at 23:55 and calculates the average of the temperature and humidity from that day and inserts it to the avg_temp table.</p>
  
  <p>There're some basic structures of my tables: </p>
  
  <p><strong>avg_temp table:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/wFtYD.png" alt="avg_temp table"></p>
  
  <p><strong>stats table:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/d0HtA.png" alt="stats table"></p>
  
  <p>It might be something like this, but it doesn't work for me, but I hope you get the idea about what I need to accomplish from that. </p>
  
  <pre><code>SELECT `timestamp`,AVG(`humidity`) as avgHumid
  FROM stats
  GROUP BY `timestamp`
  SELECT `timestamp`,AVG(`temperature_C`) as avgTemp
  FROM stats
  GROUP BY `timestamp`
  INSERT INTO avg_temp (avg_temp, avg_humid) values('$avgTemp', '$avgHumid')
  </code></pre>