如何减少 sql 语句中的多个 and- 和 or- 条件?

How to reduce this multiple and- and or- conditions in sql-statement?

我有一个关于 SQL 的优化问题。

有没有办法减少这种 sql 语法:

Select * from TABLE 
where 
COLUMN != 'abc' and 
COLUMN != 'def' and 
COLUMN != 'xau' and 
COLUMN != 'def' and 
COLUMN != 'eag' and 
COLUMN != 'dff' and 
COLUMN != 'www' 

和第二种sql语法

Select * from TABLE 
where 
COLUMN = 'abc' or 
COLUMN = 'def' or 
COLUMN = 'xau' or 
COLUMN = 'def' or 
COLUMN = 'eag' or 
COLUMN = 'dff' or 
COLUMN = 'www' 

试试这个:

多个 OR 条件可以重写为:

Select * from TABLE 
where 
COLUMN not in('abc','def','xau','def','eag','dff','www')

多个AND条件,请教一下同一列有可能超过1个值的情况吗?

使用布尔代数:

第一名:(!x)AND(!y)..AND(!z) == !(x or y...or z)

含义:

 Select * from TABLE WHERE COLUMN NOT IN ('abc','def',...)





    2nd:  (!x)or(!y)..or(!z)==!(x AND Y AND ..Z) 
 however  the intersection of  x AND Y ... AND Z  is the empty set.
So  (!x)or(!y)..or(!z)==!(x AND Y AND ..Z)  = !(False) = True.

Meaning:

    Select * from TABLE  //no WHERE CLAUSE NEEDED