Re: How to delete intersection of two tables?

From: <hatzinger_m_at_bmwf1f.bmwf.gv.at>
Date: 15 Apr 93 07:43:38 +0100
Message-ID: <1993Apr15.074338.73_at_bmwf1f.bmwf.gv.at>


In article <1993Apr14.074621.7524_at_daimi.aau.dk>, ludvig_at_daimi.aau.dk (Peter Hubel) writes:
> Hi netters,
>
> I'm quite a novice into Oracle SQL and I have this
> problem.
>
> I have two tables (T1 and T2) which have two fields
> (let's call them A and B) in common. The goal is to
> remove all rows in T1 which match a row in T2 w.r.t
> A and B.
>
> I've tried something like
>
> DELETE FROM T1 x
> WHERE A = (SELECT A FROM T2 y WHERE T1.B = T2.B)
>
> but it doesn't seem to work at all.
>
> Any suggestions, anybody?

DELETE FROM t1
 WHERE EXISTS (SELECT 1

                 FROM T2
                WHERE T1.A=T2.A
                  AND T1.B=T2.B)

/

kind regards

Mike


                                                                          ^
 Federal Ministry of Science and Research                               B | M
<-------------------------------------------------------------------------+---->
 Computer Center                                                        W | F
                                                                          |
 Ing. Klaus-Michael Hatzinger       mail: hatzinger_m_at_mail.bmwf.gv.at     |
 Bankgasse 1/209                   phone: 0043-222-53120/5188             |
 1014 Vienna, Austria                fax: 0043-222-53120/5180             V
================================================================================
======      ORACLE-Application developer and Database Administrator       ======
======      Using Oracle V6.0.34 on DEC/VMS, V6.0.36 on RISC/ULTRIX       ======
================================================================================
Received on Thu Apr 15 1993 - 08:43:38 CEST

Original text of this message