select distinct(f_fac.cd_facid),lig_date,fac_num,cd_soin,cd_forf,cd_abon,cd_bout,cd_reg,lig_tp_lig,lig_mt_tot from f_fac left join f_lig on f_lig.cd_facid=f_fac.cd_facid where fac_num is null and lig_date<'31/10/2010' and lig_tp_lig <>'G' and lig_tp_lig <>'A' ----------------------------------------------- update f_lig set lig_ticket='2' where f_lig.cd_facid in ( select f_fac.cd_facid from f_fac where f_lig.cd_facid=f_fac.cd_facid and f_fac.fac_num is null and f_lig.lig_date<'31/12/2005' and f_lig.lig_tp_lig <>'A'and f_lig.lig_tp_lig <>'G' ) --------------------------------------------------- select f_fac.cd_facid,cf_euros,fac_date from f_fac where f_fac.cd_facid in ( select f_lig.cd_facid from f_lig where f_fac.fac_num is null and f_lig.lig_date<'31/12/2005' and f_lig.lig_ticket=2 ) ---------------------------------------------------- update f_fac set cf_euros=2 where f_fac.cd_facid in ( select f_lig.cd_facid from f_lig where f_fac.fac_num is null and f_lig.lig_date<'31/12/2005' and f_lig.lig_ticket=2 ) ---------------------------------------------------- select * from f_lig where lig_ticket=2 ------------------------------------------------- delete from f_lig where lig_ticket=2 ----------------------------------------------- select * from f_fac where cf_euros=2 -------------------------------------------- delete from f_fac where cf_euros=2