Deleting using LEFT JOIN
SAMPLE. DELETE RECORD IN TABLE 'A' IS THERE ARE NOT RECORD IN TABLE 'H'
DELETE A FROM ARTICULO_ALMACEN ALEFT JOIN HISTORICO_UNION HON A.COD_ARTICULO = H.COD_ARTICULOAND A.COD_ALMACEN = H.COD_ARTICULO_ALMACENAND A.TPROPIEDAD1 = H.PROPIEDAD1AND A.TPROPIEDAD2 = H.PROPIEDAD2AND A.TPROPIEDAD3 = H.PROPIEDAD3WHERE H.COD_ARTICULO IS NULL
From where I see it, you don't actually need a join to perform this...
DELETE FROM coursework.leadCustomer WHERE leadCustomer.customerID NOT IN (SELECT distinct customerID FROM coursework.flightBooking where status IN ('R','H') )AND leadCustomer.customerID = 8;
it will delete all records in leadcustomer with a customerID that is :1) different from 82) Not in table flightbooking with status 'R' or 'H'
Isn't that what you're trying to do ?
You will need to do this:
Delete from TableAwhere ID in (select ID from tableA a left outer join tableB b on a.ID = b.ID where b.ID is NULL)