SQL 中的双重否定 - NOT (Food != "Apple") 的含义

Double negative in SQL - meaning of NOT (Food != "Apple")

双重否定含义有问题。

这些语句是否等价?

  1. 不是(食物 <> "Apple" 不是(食物 = "Banana"))

===

  1. (食物 = "Apple" 和食物 = "Banana")

您正在寻找De Morgan's laws

NOT( A OR B )  = NOT A AND NOT B
NOT( A AND B ) = NOT A OR  NOT B

所以第一句应该是:

NOT (Food <> "Apple" AND NOT (Food = "Banana"))
==> NOT (Food <> "Apple" AND Food <> "Banana")       -- SOLVE inner NOT
==> NOT (Food <> "Apple") OR NOT (Food <> "Banana")  -- MORGAN LAW
==> Food = "Apple" OR Food = "Banana"                -- APPLY NOT