Saya pikir ini yang Anda maksud:
with recursive tc as(
select $1 as player_id, 1 as level
union
select ph2.player_id, level+1
from tc, phone_hashes ph1, phone_hashes ph2
where tc.player_id=ph1.player_id
and ph1.hash=ph2.hash
and tc.level < 6
)
select distinct player_id from tc