Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Need help with a query

Re: Need help with a query

From: Michael Serbanescu <mserban_at_postoffice.worldnet.att.net>
Date: 1998/03/23
Message-ID: <6f70n8$nqf@bgtnsc02.worldnet.att.net>#1/1

Try this:

DELETE [FROM] TableA t1
WHERE (t1.I_id, t1.I_date, t1.I_code, t1.I_start_time, t1.I_stop_time) IN (SELECT (t2.E_id, t2.E_date, t2.E_code, t2.E_start_time, t2.E_stop_time)  FROM TableB t2, TableA t1

 WHERE t2.E_id = t1.I_id
 AND t2.E_date = t1.I_date
 AND t2.E_code = t1.I_code

 AND t2.E_start_time = t1.I_start_time
 AND t2.E_stop_time = t1.I_stop_time
)
;

Hope this helps.

Michael Serbanescu



dwarakv_at_hotmail.com wrote:
>
> Hi,
> I have two tables A and B. I need to delete those records from table A
> which match records in Table B. The description of the two tables are
>
> Table A Table B
> I_id Number E_id Number
> I_date Date E_date Date
> I_code Varchar2(20) E_code Varchar2(20)
> I_start_time Date E_start_time Date
> I_stop_time Date E_stop_time Date
> I_time Number
> I_a_flag Varchar2(1)
> I_p_flag Char(1)
>
> e.g.,
> Table A contains
>
> 8741 22-MAR-98 Open 22-MAR-98 22-MAR-98 .98333333 N Y
> 8741 22-MAR-98 Lunch 22-MAR-98 22-MAR-98 .98333333 N Y
> 7864 21-MAR-98 Open 21-MAR-98 21-MAR-98 .98333333 N Y
> 7864 21-MAR-98 Lunch 21-MAR-98 21-MAR-98 .98333333 N Y
>
> and table B contains
>
> 8741 22-MAR-98 Open 22-MAR-98 22-MAR-98
> 7864 21-MAR-98 Lunch 21-MAR-98 21-MAR-98
>
> In this e.g., I would like to delete the first and the last record in table
> A. The start_time and the stop_time hold the time along with the dates.Can
> someone help me with a query for this.
>
> Thanks,
> Dwarak
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
Received on Mon Mar 23 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US