[SQL문제풀기] 세 명이 서로 친구인 관계 찾기

silver's avatar
Oct 01, 2025
[SQL문제풀기] 세 명이 서로 친구인 관계 찾기

문제

: 쿼리 실행에 오랜시간 소요

SQLite

내가 작성한 정답

select a.user_a_id, b.user_a_id user_b_id ,c.user_b_id user_c_id from edges a join edges b on a.user_b_id = b.user_a_id join edges c on a.user_a_id = c.user_a_id and b.user_b_id = c.user_b_id where 3820 in (a.user_a_id,b.user_a_id,c.user_b_id);
Share article

silver