title: how to update a sql database table based on the condition from another table in the same database
body: <p>I have a two tables in a database. </p>
  
  <pre><code>table_1(device_ID, date,voltage)
  
  table_2(device_ID,device_status)
  </code></pre>
  
  <p>I am trying to create an event to execute every 5 minutes. </p>
  
  <p>What I am trying to achieve is, select device_ID from table_1 if there is no new data over the last 10 minutes and update the table_2, that means set device_status to 0. </p>
  
  <p>How do i pass conditions between two tables? </p>
  
  <pre><code>BEGIN 
    select device_ID from table_1 where date =  DATE_SUB(NOW(), INTERVAL 10 Minutes);                          
  
  //here i will get device_IDs if there was a data within last 10 minutes. 
  
  //but i need device_ID if there were no data. 
  
  //how to update table_2 based on the above condition?
  
  END
  </code></pre>