Hi
I have 2 tables :
t1 is the main data table with 3 fields
t2 is a driver table which will drive the delete
t1 t2
========== ======
f1 f2 f3 f1 f2
a 1 do a 1
a 2 re b 2
b 2 mi c 5
c 2 fa
c 3 so
I want to delete all rows from t1 where the f1 AND f2 field values exist in t2 (i.e. rows 1 and 3)
A select would go like this :
select * from t1 A, t2 B where A.f1=B.f1 and A.f2=B.f2
Unfortunately this does not work for delete. The closest I though might work was :
delete from t1 where t1.f1=t2.f1 and t1.f2=t2.f2
I looked at subqueries :
delete from t1 where
f1 in (select f1 from t2) and
f2 in (select f2 from t2)
However this would just delete any rows with an f1=a or b or an f2=1 or 2. Including a,2 and c,2 which do NOT exist in driver table and should not be deleted.
This is quite urgent as per usual I have people on my back. Help MUCH appreciated.
I have 2 tables :
t1 is the main data table with 3 fields
t2 is a driver table which will drive the delete
t1 t2
========== ======
f1 f2 f3 f1 f2
a 1 do a 1
a 2 re b 2
b 2 mi c 5
c 2 fa
c 3 so
I want to delete all rows from t1 where the f1 AND f2 field values exist in t2 (i.e. rows 1 and 3)
A select would go like this :
select * from t1 A, t2 B where A.f1=B.f1 and A.f2=B.f2
Unfortunately this does not work for delete. The closest I though might work was :
delete from t1 where t1.f1=t2.f1 and t1.f2=t2.f2
I looked at subqueries :
delete from t1 where
f1 in (select f1 from t2) and
f2 in (select f2 from t2)
However this would just delete any rows with an f1=a or b or an f2=1 or 2. Including a,2 and c,2 which do NOT exist in driver table and should not be deleted.
This is quite urgent as per usual I have people on my back. Help MUCH appreciated.