Re: Brain Freeze - Request Delete Syntax Help

From: Doug Miller <spambait_at_milmac.com>
Date: Fri, 29 Feb 2008 15:08:30 GMT
Message-ID: <OdVxj.8219$Ru4.1782@newssvr19.news.prodigy.net>


In article <OpUxj.22325$y05.12777_at_newsfe22.lga>, "Buck Turgidson" <jc_va_at_hotmail.com> wrote:
>I need to reverse the logic of a SELECT statement, and change it into a
>DELETE statement.
>
>Do I have this right? Does this:
>--------------
>select * from
>mytable.
>where ( aggr = '1' OR ( aggr = '3' AND agg_d <> 'X' ) ).
>--------------
>Convert to this for a table that is loaded without the above where clause?
>--------------
>delete from mytable
> where ( aggr <> '1' and ( aggr <> '3' AND agg_d = 'X' ) ).
>--------------

No; the second AND should be OR instead:

You want to negate an expression of the form (A OR B). NOT (A OR B) = (NOT A) AND (NOT B)
But in this case, B is the compound condition (C AND D) Thus (NOT B) = (NOT (C AND D)) = (NOT C) OR (NOT D) And the final condition is (NOT A) AND ((NOT C) OR (NOT D)). Received on Fri Feb 29 2008 - 09:08:30 CST

Original text of this message