Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Request help from SQL Gurus
gthorne777_at_my-deja.com wrote in message <7ika2p$86l$1_at_nnrp1.deja.com>...
>I have two tables. We'll call them TABLE1
>and TABLE2 for this example. I have rows in both tables that I want to
>delete based on a condition in TABLE1. For exaple, let's say TABLE1 has
>the following rows:
> DATE INTEGER
> BATCH_ID INTEGER
> DEST CHAR(8)
>
>and TABLE2 has the following rows:
> BATCH_ID INTEGER
> DEST CHAR(8)
> NAME CHAR(25)
> ADDR CHAR(50)
> ZIP CHAR(50)
> PHONE CHAR(15)
>
>I want to delete the records in TABLE1 before a certain date, and also
>delete the records in TABLE2 that have a corresponding BATCH_ID and
>DEST. What would be the easiest way to do this? I'm re-writing a
>program that did it by doing a SELECT statement on the first table,
>parsing the output, and deleting the corresponding records in TABLE2. I
>think there has to be a better way.
> -Greg
There is.
delete table2
where table1.batch_id = table2.batch_id
and table1.date < {certain date goes here};
And then,
delete table1
where table1.date < {certain date goes here, too};
![]() |
![]() |