Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: One DELETE with OR clause behaves differently from two DELETEs ?
> 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" - UnknownReceived on Fri Sep 01 2006 - 08:03:17 CDT