How can I delete the records returned by the following query?
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) > 10
Group By SUBSTRING(Code,1,10)
Having COUNT(SUBSTRING(Code,1,10)) > 1) P
on SUBSTRING(HL.User,1,10) = P.Code
Group By HL.User
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.
Thanks
Try this: