如何读取我也在MySQL中更新的表?

时间:2013-01-10 05:26:01

标签: mysql

更新声明

UPDATE a_fees af set af.audit_id =  get_audit_id ( pubco_id, auditor_id, 
                                                   (SELECT 
                                                    CONCAT ('''', 
                                                      a_fees.fiscal_year, '', 
                                                      fiscal_period_end_month,'',
                                                      fiscal_period_end_day, '''')
                                                   FROM a_fees, a_fiscal_period_end
  WHERE a_fees.fiscal_period_end_id = a_fiscal_period_end.fiscal_period_end_id)
);

错误消息

#1093 - You can't specify target table 'af' for update in FROM clause

1 个答案:

答案 0 :(得分:0)

根据this ,这应该有效:

UPDATE a_fees set audit_id =  get_audit_id ( pubco_id, auditor_id, 
                                                   (SELECT 
                                                    CONCAT ('''', 
                                                      af.fiscal_year, '', 
                                                      fiscal_period_end_month,'',
                                                      fiscal_period_end_day, '''')
                                                   FROM a_fees af, a_fiscal_period_end
  WHERE af.fiscal_period_end_id = a_fiscal_period_end.fiscal_period_end_id)
);