title: Deleting Returned SQL results
body: <p>How can I delete the records returned by the following query?</p>
  
  <pre><code>Select HL.User from "Hobby List" HL 
  INNER JOIN (Select SUBSTRING(Code,1,10) Code,Count(SUBSTRING(CODE,1,10))
  AS Occurances from Patient where length(Patient.Code) &gt; 10
  Group By SUBSTRING(Code,1,10)
  Having COUNT(SUBSTRING(Code,1,10)) &gt; 1) P
  on SUBSTRING(HL.User,1,10) = P.Code
  Group By HL.User
  </code></pre>
  
  <p>I tried to delete the records by using a "delete if exists" approach which was either wrong or I didn't do it properly because it deleted all the records in the table instead of just the ones returned by my query.</p>
  
  <p>Thanks </p>