Re: Brain Freeze - Request Delete Syntax Help

From: Doug Miller <>
Date: Fri, 29 Feb 2008 15:08:30 GMT
Message-ID: <OdVxj.8219$>

In article <OpUxj.22325$y05.12777_at_newsfe22.lga>, "Buck Turgidson" <> 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
>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