执行如下语句 update payment set end_date=date_add(end_date,interval 0 day)
where payment_id=(select payment_id from payment where date(now())>=date(begin_date)
and date(now())<=date(end_date)
and cust_id='0020001081100047'
and Operation_Type='1'); 老是报you can't specify target table 'payment' for update in from clause错误。为啥?
where payment_id=(select payment_id from payment where date(now())>=date(begin_date)
and date(now())<=date(end_date)
and cust_id='0020001081100047'
and Operation_Type='1'); 老是报you can't specify target table 'payment' for update in from clause错误。为啥?
on a.payment_id=b.payment_id
set end_date=date_add(end_date,interval 0 day)
where date(now())>=date(b.begin_date) and date(now()) <=date(b.end_date)
and b.cust_id='0020001081100047'
and b.Operation_Type='1'
错误的原因是you can't specify target table 'payment' for update in from clause
翻译如下,你应该就明白了,你不能指定目标表payment来使用from的更新条件
http://answers.google.com/answers/threadview?id=475696
on a.payment_id=b.payment_id
set a.end_date=date_add(a.end_date,interval 0 day)
where date(now())>=date(b.begin_date) and date(now()) <=date(b.end_date)
and b.cust_id='0020001081100047'
and b.Operation_Type='1'