gpt4 book ai didi

mysql - 选择 1 - 选择 2

转载 作者:搜寻专家 更新时间:2023-10-30 23:38:06 26 4
gpt4 key购买 nike

在查询中,
select id,name,feature,marks from (....)
我想删除其 id 在另一个 select 语句中存在的那些。
从 (...) 中选择 id

我是 sql 新手。是否有直接执行此操作的语句?

最佳答案

几种方法。

Join:

select t1.id, t1.name, t1.feature, t1.marks 
from t1
left outer join (some select statement) t2
on t1.id = t2.id
where t2.id is null

Antijoin:

select t1.id, t1.name, t1.feature, t1.marks 
from t1
where not exists (
select id
from (some select statement) t2
where t2.id = t1.id
)

"Not In":

select t1.id, t1.name, t1.feature, t1.marks 
from t1
where t1.id not in (
select id
from (some select statement)
)

关于mysql - 选择 1 - 选择 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38864739/

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