Reputation: 45
I have this select statement:
select *
from users u
where u.user_id in (
select distinct user_id
from user_filial
where filial_id in (
select filial_id
from user_filial
where user_id = 101
)
);
I need covert this to statement with Joins.
Upvotes: 0
Views: 1175
Reputation: 3437
SELECT U.*
FROM
users U
INNER JOIN user_filial UF ON UF.filial_id = U.filial_id
WHERE U.user_id = 101
Upvotes: 1
Reputation: 424983
This is the equivalent query expressed using joins:
select distinct u.*
from user_filial uf
join user_filial uf2 on uf2.filial_id = uf.filial_id
join users u on u.user_id = uf2.user_id
where uf.user_id = 101
Upvotes: 0