'SO-22/03862','SO-22/03855','SO-22/03851','SO-22/03850','SO-22/03849','SO-22/03848','SO-22/03847','SO-22/03846','SO-22/03845','SO-22/03844','SO-22/03843','SO-22/03842','SO-22/03841','SO-22/03840','SO-22/03839','SO-22/03838','SO-22/03837','SO-22/03834','SO-22/03833','SO-22/03831','SO-22/03830','SO-22/03829','SO-22/03824','SO-22/03823','SO-22/03822','SO-22/03821','SO-22/03820','SO-22/03819','SO-22/03818','SO-22/03817','SO-22/03816','SO-22/03815','SO-22/03814','SO-22/03813','SO-22/03808','SO-22/03882','SO-22/03881','SO-22/03880','SO-22/03879','SO-22/03878','SO-22/03877','SO-22/03876','SO-22/03875','SO-22/03874','SO-22/03873','SO-22/03872','SO-22/03871','SO-22/03870','SO-22/03869','SO-22/03868','SO-22/03867','SO-22/03866','SO-22/03864','SO-22/03863','SO-22/03909','SO-22/03908','SO-22/03907','SO-22/03906','SO-22/03905','SO-22/03904','SO-22/03903','SO-22/03902','SO-22/03901','SO-22/03900','SO-22/03899','SO-22/03898','SO-22/03897','SO-22/03896','SO-22/03895','SO-22/03894','SO-22/03892','SO-22/03886','SO-22/03885','SO-22/03884','SO-22/03883'



SELECT * from 0p4_sale_order where sale_order_no in ('SO-22/03862','SO-22/03855','SO-22/03851','SO-22/03850','SO-22/03849','SO-22/03848','SO-22/03847','SO-22/03846','SO-22/03845','SO-22/03844','SO-22/03843','SO-22/03842','SO-22/03841','SO-22/03840','SO-22/03839','SO-22/03838','SO-22/03837','SO-22/03834','SO-22/03833','SO-22/03831','SO-22/03830','SO-22/03829','SO-22/03824','SO-22/03823','SO-22/03822','SO-22/03821','SO-22/03820','SO-22/03819','SO-22/03818','SO-22/03817','SO-22/03816','SO-22/03815','SO-22/03814','SO-22/03813','SO-22/03808','SO-22/03882','SO-22/03881','SO-22/03880','SO-22/03879','SO-22/03878','SO-22/03877','SO-22/03876','SO-22/03875','SO-22/03874','SO-22/03873','SO-22/03872','SO-22/03871','SO-22/03870','SO-22/03869','SO-22/03868','SO-22/03867','SO-22/03866','SO-22/03864','SO-22/03863','SO-22/03909','SO-22/03908','SO-22/03907','SO-22/03906','SO-22/03905','SO-22/03904','SO-22/03903','SO-22/03902','SO-22/03901','SO-22/03900','SO-22/03899','SO-22/03898','SO-22/03897','SO-22/03896','SO-22/03895','SO-22/03894','SO-22/03892','SO-22/03886','SO-22/03885','SO-22/03884','SO-22/03883')








SELECT d.* from 0p4_sale_order_detail d left join 0p4_sale_order so on d.sale_order_id=so.sale_order_id where so.sale_order_no in ('SO-22/03862','SO-22/03855','SO-22/03851','SO-22/03850','SO-22/03849','SO-22/03848','SO-22/03847','SO-22/03846','SO-22/03845','SO-22/03844','SO-22/03843','SO-22/03842','SO-22/03841','SO-22/03840','SO-22/03839','SO-22/03838','SO-22/03837','SO-22/03834','SO-22/03833','SO-22/03831','SO-22/03830','SO-22/03829','SO-22/03824','SO-22/03823','SO-22/03822','SO-22/03821','SO-22/03820','SO-22/03819','SO-22/03818','SO-22/03817','SO-22/03816','SO-22/03815','SO-22/03814','SO-22/03813','SO-22/03808','SO-22/03882','SO-22/03881','SO-22/03880','SO-22/03879','SO-22/03878','SO-22/03877','SO-22/03876','SO-22/03875','SO-22/03874','SO-22/03873','SO-22/03872','SO-22/03871','SO-22/03870','SO-22/03869','SO-22/03868','SO-22/03867','SO-22/03866','SO-22/03864','SO-22/03863','SO-22/03909','SO-22/03908','SO-22/03907','SO-22/03906','SO-22/03905','SO-22/03904','SO-22/03903','SO-22/03902','SO-22/03901','SO-22/03900','SO-22/03899','SO-22/03898','SO-22/03897','SO-22/03896','SO-22/03895','SO-22/03894','SO-22/03892','SO-22/03886','SO-22/03885','SO-22/03884','SO-22/03883')



// Old DB Info
// max so table id :  15910
// max so detail id : 286363

15676 => 15911 = 235

281993 => 286364 = 4371

ALTER TABLE `0p4_sale_order` 
ADD COLUMN `ref_new_so_no` varchar(1024) NULL AFTER `addon_amount`;

update 0p4_sale_order_detail set sale_order_detail_id=sale_order_detail_id+4371,sale_order_id=sale_order_id+235;

update 0p4_sale_order set sale_order_id=sale_order_id+235;


update 0p4_sale_order set ref_new_so_no=sale_order_no;


update 0p4_sale_order s left join so_match m on m.new_so_no=s.sale_order_no
set s.sale_order_no=m.old_so_no;