There are two tables Zakazi and Isp_zak
In the table Zakazi trace. columns: id_table, kod_kl, pod_kod_exped, kod_kl_grotpr, u_kod, vesgr, count_vag, CodeGruN, vocode, period_per, dt_zak, stcode, nnod, kod_jd, zak_comlite, smgs
In the Isp_zak table, the following columns: id_table, pod_kod_exped, nomot, nomvag, kodgr, dt_otpr, stotpr, dvydsd, stnds, abr_val, vesgr, uni_id, messvid, id_table_zak
It is necessary to write UPDATE for the Isp_zak table for the id_table_zak field with data from the zakazi table from the id_table field. Provided that the number of duplicate values of id_table orders does not exceed the value of count_vag from the Zakazi table?
With the implementation of these conditions, everything is simple Zakazi.pod_kod_exped = Isp_zak.pod_kod_exped and Zakazi.CodeGruN = Isp_zak.kodgr and Zakazi.dt_zak <Isp_zak.dt_otpr