with recursive anc1 as(select * from t_person where id=1673247 UNION select p.* from t_person p join anc1 on anc1.idf=p.id or anc1.idm=p.id), anc2 as(select * from t_person where id=1673246 UNION select p.* from t_person p join anc2 on anc2.idf=p.id or anc2.idm=p.id) select max(py) py,max(pr) pr,lat,lon,group_concat(u.id,': ',u.Nom,' | ',u.Prenom SEPARATOR '\n') p from (select anc1.* from anc1 join anc2 using(id)) as u join plr using(id) join places on n_lid=lid or d_lid=lid where lat is not null group by lat,lon