gpt4 book ai didi

mysql - SQL Server all(select ...) 为空

转载 作者:行者123 更新时间:2023-11-29 12:04:40 25 4
gpt4 key购买 nike

我搜索过,但找不到任何相关信息。我需要像

这样的 SQL 服务器查询
select t1.x 
from @tablename as t1
where all
(select t2.y from @tablename as t2 where t1.x=t2.x) is null

@tablename 是相同的

但我不能使用查询的 all(select ...) is null 部分。

谢谢。

最佳答案

您想要不存在吗?

select t1.x 
from @tablename as t1
where not exists (select t2.y from @tablename as t2 where t1.x = t2.x)

这测试没有匹配的值。

或者,也许,

select t1.x 
from @tablename t1
where not exists (select 1
from @tablename as t2
where t1.x = t2.x and t2.y is not null
) ;

这测试 y 的任何匹配值是否具有 NULL

关于mysql - SQL Server all(select ...) 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31722522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com