The ON clause specifies that the join be performed based on the values of the ID numbers from each table.
on p.IdNumber=p2.idnum;