我通常采用这种join
方法,但在这种情况下我有点困惑。我什至不确定这是否可能。我想知道是否可以将以下查询转换为left join
查询而不是使用多个select in
:
select
users.id, users.first_name, users.last_name, users.description, users.email
from users
where id in (
select assigned.id_user from assigned where id_project in (
select assigned.id_project from assigned where id_user = 1
)
)
or id in (
select projects.id_user from projects where projects.id in (
select assigned.id_project from assigned where id_user = 1
)
)
此查询返回正确的结果集。但是,我想重复选择的查询assigned.id_project
是一种浪费。