简体   繁体   English

Where子句-不喜欢声明

[英]Where clause - Not Like Statement

i got a statement where i got a where clause like this: 我有一个声明,其中有一个where子句,例如:

AND  (  (ROOT_CAUSE_CODE like 'X%' OR ROOT_CAUSE_CODE like 'D%') AND (SUMMARY_DESC like 'COMPLETE%' or SUMMARY_DESC like 'MULTIPLE%') and SERVICE_LEVEL='TOP' and SERVICE_AFFECTED='1'  ) 

Now i want to create a second query, where i get exactly the opposite of those values of the first where clause. 现在,我想创建第二个查询,在这里我得到与第一个where子句的值完全相反的查询。 So i will use same statment but with a where clause which gives me all the values not like the first where clause? 因此,我将使用相同的陈述,但是使用where子句,该子句为我提供了所有值,而不是第一个where子句?

How can i achieve that? 我该如何实现?

THX and BR Joe THX和BR Joe

If we assume that none of the columns are NULL , then the opposite is: 如果我们假设所有列都不为NULL ,则相反的是:

AND NOT ( (ROOT_CAUSE_CODE like 'X%' OR ROOT_CAUSE_CODE like 'D%') AND
          (SUMMARY_DESC like 'COMPLETE%' or SUMMARY_DESC like 'MULTIPLE%') and
          SERVICE_LEVEL = 'TOP' and SERVICE_AFFECTED = '1'
       ) 

If the values can be NULL than the logic is more complicated. 如果值可以为NULL ,则逻辑会更复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM