如何检查 TSQL 中 WHERE 语句中的逻辑比较是 TRUE 还是 FALSE?

发布于 2024-12-26 11:03:52 字数 406 浏览 0 评论 0原文

我怎样才能完成这个查询,以便我可以检查逻辑比较的结果是否为FALSE:

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE ( ( table1.Value IS NULL) AND 
         ( table2.Value IS NULL) AND
         ( table3.Value IS NULL) AND
          ( table4.Value IS NULL) ) -- Here I want to ADD something like IS FALE; 
                                    --How can I do this?

How can I accomplish this query so that I can check the logical comparison's result is FALSE:

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE ( ( table1.Value IS NULL) AND 
         ( table2.Value IS NULL) AND
         ( table3.Value IS NULL) AND
          ( table4.Value IS NULL) ) -- Here I want to ADD something like IS FALE; 
                                    --How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

宛菡 2025-01-02 11:03:52

使用 NOT 操作数

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE NOT ( ( table1.Value IS NULL) AND 
            ( table2.Value IS NULL) AND
            ( table3.Value IS NULL) AND
            ( table4.Value IS NULL)
          )

Use the NOT operand

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE NOT ( ( table1.Value IS NULL) AND 
            ( table2.Value IS NULL) AND
            ( table3.Value IS NULL) AND
            ( table4.Value IS NULL)
          )
2025-01-02 11:03:52

您有几个选项

NOT

...(Table4.value IS NOT NULL)...
...NOT (Table4.value IS NULL)...

CASE

CASE WHEN (<复杂比较> = somevalue THEN 1 ELSE 0) = 0< /代码>

You have a few options

NOT

...(Table4.value IS NOT NULL)...
...NOT (Table4.value IS NULL)...

CASE

CASE WHEN (<complex comparison> = somevalue THEN 1 ELSE 0) = 0

女皇必胜 2025-01-02 11:03:52

您的意思是:

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE (
        NOT(    
         ( table1.Value IS NULL) AND 
         ( table2.Value IS NULL) AND
         ( table3.Value IS NULL) AND
         ( table4.Value IS NULL)
          ) 
      )

Do you mean:

SELECT *
FROM table1
INNER JOIN table2 ...
INNER JOIN table3 ...
INNER JOIN table4 ...
WHERE (
        NOT(    
         ( table1.Value IS NULL) AND 
         ( table2.Value IS NULL) AND
         ( table3.Value IS NULL) AND
         ( table4.Value IS NULL)
          ) 
      )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文