gpt4 book ai didi

sql - SQL 导航器中的 "with... as"

转载 作者:行者123 更新时间:2023-12-04 14:15:49 25 4
gpt4 key购买 nike

以下查询有效:

select count(*) from everything where num not in (select num from sometable)

以下查询应该等同于上述查询,但会导致“无效标识符”错误:
with unwanted as (select num from sometable)
select count(*) from everything where num not in unwanted

第二个查询有什么问题?

最佳答案

语法是这样的:

with unwanted as (select num from sometable)
select count(*) from everything where num not in (select * from unwanted)

显然这只有在 select num from sometable 时才有意义部分有点复杂或稍后使用几次......

关于sql - SQL 导航器中的 "with... as",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12692430/

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