表vales
id Name
1 rahul
2 john
3 Aswin
4 jerry
5 jack
6 john我想打印唯一的名字,即在查询中没有john使用Exists或Not Exists的列表。
发布于 2020-12-04 18:16:44
您可以执行以下操作:
select name
from vales v
where not exists (select 1 from vales v1 where v1.name = v.name and v1.id <> v.id)请注意,聚合也是一种可能的解决方案(尽管这不使用exists):
select name
from vales
group by name
having count(*) = 1https://stackoverflow.com/questions/65141700
复制相似问题