select *
FROM

(
SELECT w13.nr01 as t_nr01,
       w13.nr01 as t_newnr,
       w13.p01  as t_p01,
       w13.p02  as t_p02,
       w13.p03  as t_p03,
       w13.p07  as t_p07,
        0       as t_del,
        0  as t_p101,
        0  as t_p102,
        0  as t_p103
FROM w13
WHERE w13.p01='{np01}'

UNION

SELECT
       0 as t_nr01,
       0 as t_newnr,
 space(10)  as t_p01,
   d80.p02  as t_p02,
   d80.p03  as t_p03,
         0  as t_p07,
         0  as t_del,
   d80.nr01 as t_p101,
   if(w22.p04 is null, 0, w22.p04) as t_p102,
   if(w22.nr01 is null, 0, w22.nr01) as t_p103
FROM d80
LEFT JOIN w22 ON w22.p01='{np01}'
              && w22.p02='D80_1'
              && w22.p03=d80.nr01
WHERE {p_us5where}
) as t1 ;