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

Home -> Community -> Usenet -> c.d.o.misc -> Re: One DELETE with OR clause behaves differently from two DELETEs ?

Re: One DELETE with OR clause behaves differently from two DELETEs ?

From: Brian Peasland <dba_at_nospam.peasland.net>
Date: Fri, 1 Sep 2006 13:03:17 GMT
Message-ID: <J4x09n.6u6@igsrsparc2.er.usgs.gov>


> DELETE FROM MACHINE_DOWN_TIMES
> WHERE STOP_MEASURE_ID IN (
> SELECT ID FROM MEASURES WHERE ORDER_ID = :p_order_id AND TIME_STAMP >
> :p_order_end_date
> )
> OR STOP_END_MEASURE_ID IN (
> SELECT ID FROM MEASURES WHERE ORDER_ID = :p_order_id AND TIME_STAMP >
> :p_order_end_date
> );

Why not write the above as follows:

DELETE FROM MACHINE_DOWN_TIMES
WHERE STOP_MEASURE_ID IN (
   SELECT ID FROM MEASURES
   WHERE (ORDER_ID = :p_order_id AND TIME_STAMP > :p_order_end_date)

      OR (ORDER_ID = :p_order_id2 AND TIME_STAMP > :p_order_end_date2)

HTH,
Brian

-- 
===================================================================

Brian Peasland
dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Received on Fri Sep 01 2006 - 08:03:17 CDT

Original text of this message

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