Thanks apmuthu

I understand now

Thanks Joe

I see this happen, the trans_nr is now known to me

SELECT max(last_no) last_no FROM (
SELECT MAX(`trans_no`) as last_no FROM 0_debtor_trans WHERE `type`='13'
UNION SELECT MAX(`id`) as last_no FROM 0_voided WHERE `type`='13') a

But what is the purpose of the voided table?

can someone explain to me what it is the trans_nr in the 0_debtor_trans , and where it comes from