select tabla01.id_p, nombre, max(fecha) as fechamax from tabla01 inner join tabla02 on tabla01.id_p=tabla02.id_p group by tabla01.id_p, nombre