正如标题所暗示的那样,重写它以仅将排除作为连接的方法是什么?
select users.id from users where id not in ("select
pu.owner_id from projects p
inner join
projects_users pu on
pu.owned_project_id = p.id
where p.project_name = 'This is an example of a project'")
我认为这可能有效,但它不会从 project_users 中不存在的用户返回任何内容:
select u.id from users u
left outer join projects_users pu on
pu.owner_id = u.id
inner join projects p on
pu.owned_project_id = p.id
where NOT p.project_name = 'This is an example of a project'