首页 > 解决方案 > 如何将 SQL 中的当前 QUERY 转换为不同的数据

问题描述

我正在尝试在 SQL 中使用此 QUERY

select homework
from karlos
except
select k_id
from yara
where y_ID is not null;

更新:基本上我只想将最上面的查询重写为另一个输出相同结果但使用没有子查询或集合操作的外连接的查询

标签: sqlpostgresql

解决方案


我想你想要not exists

select s.ID
from student
where not exists (select 1
                  from advisor a
                  where a.s_id = s.id and a.i_id is not null
                 );

推荐阅读