Il distinct si estende a tutti quanti i campi, usa il group by ed eventualmente vedi se ti può servire il group_concat se necessiti di tutti gli id.