ようこそ (Jyokoso) MY BLOG

いらっしゃいませ (hajimemashite) สำหรับผู้เข้าใหม่นะค่ะ ^^V

11 ตุลาคม 2554

update for reference other table

update bg_forward_budget  
set  amount = (select amount                
                       from bg_forward_master               
                       
where forward_id =   bg_forward_budget.forward_id                 
                      and bg_type  ='FW'                 and budget_year_control =2555)             
, amount_balance =(select amount                 
                               from bg_forward_master                 
                               where forward_id = bg_forward_budget.forward_id                 
                               and bg_type  ='FW'                 
                               and budget_year_control =2555)   
,  bf_amt =(select amount                
                  from bg_forward_master                 
                  where forward_id = bg_forward_budget.forward_id                 
                  and bg_type  ='FW'                 
                  and budget_year_control =2555) 
 where bg_type  ='FW'
and budget_year_control =2555  
and amount = 0

1 ความคิดเห็น:

  1. update bg_forward_budget
    set (amount, amount_balance, bf_amt) = (select amount , amount , amount
    from bg_forward_master
    where forward_id = bg_forward_budget.forward_id
    and bg_type ='FW' and budget_year_control =2555)
    where bg_type ='FW'
    and budget_year_control =2555
    and amount = 0

    ตอบลบ