title: SQL-Delete from a table based on a nested query
body: <p>I have three tables in a mySQL databse as such:</p>
  
  <pre><code>orders: order_sequence_number, contact_id, date_ordered ...
  
  orderdetail: order_sequence_number ...
  
  person: contact_id ...
  </code></pre>
  
  <p>I am trying to delete all rows across the three tables that have a date_ordered value older than two years, however, the date_ordered field only appears in the orders table but the table has links to the other two via the order_sequence_number and contact_id fields.</p>
  
  <p>So, i'd image a bit like this: ...</p>
  
  <pre><code>SELECT * FROM orders WHERE date_ordered BETWEEN X AND Y
  </code></pre>
  
  <p>Then with that record set</p>
  
  <pre><code>DELETE FROM orderdetail WHERE orderdetail.order_sequence_number IN (THE ABOVE)
  </code></pre>
  
  <p>Etc for persons table ... but having no luck.</p>
  
  <p>Seems to me like some sort of nested subquery but I am having difficulty understanding how to do such a query and cant get my head around the convoluted nature of it...</p>
  
  <p>Any pointers would be very much appreciated.</p>