select ifnull(mydt10_1.nr01, 0)    as nr01_1, 
       ifnull(mydt10_1.p02, 0)     as p02_1, 
       ifnull(mydt10_1.p09, 0)     as p09_1, 
       ifnull(mydt10_1.rel_nr, 0)  as relnr_1, 
       ifnull(mydt10_1.uid, '')    as uid_1, 
       ifnull(mydt10_1.mark, '')   as mark_1, 
       ifnull(mydt10_2.nr01, 0)    as nr01_2, 
       ifnull(mydt10_2.p02, 0)     as p02_2, 
       ifnull(mydt10_2.p09, 0)     as p09_2, 
       ifnull(mydt10_2.rel_nr, 0)  as relnr_2, 
       ifnull(mydt10_2.uid, '')    as uid_2, 
       ifnull(mydt10_2.mark, '')    as mark_2
FROM f01
LEFT JOIN mydt10 as mydt10_1 ON mydt10_1.nr01={peg_arr[1]}
LEFT JOIN mydt10 as mydt10_2 ON mydt10_2.nr01={peg_arr[2]}
WHERE f01.nr01=1;