Hmm, don’t think you need such a subquery
select * from Activity a
where a.user_id = 'lhfcws'
and exists (select null from Joinin j
where a.user_id = j.user_id);
do the same thing
Maybe you need another check
select * from Activity a
where a.user_id = 'lhfcws'
and exists (select null from Joinin j
where a.user_id = j.user_id
and a.act_id = j.act_id);
According to @Jonathan Leffler's comment (true)
select * from Activity a
where a.user_id = 'lhfcws'
or exists (select null from Joinin j
where j.user_id = 'lhfcws'
and a.act_id = j.act_id);
source
share