例如:
update from a表 where id in( select id from a表 where ......)
mysql 會報 [Err] 1093 - You can't specify target table 'tc_cust' for update in FROM clause
MySQL手冊UPDATE documentation這下面有說明 : “Currently, you cannot update a table and select from the same table in a subquery.”
解決方法:
1,建立臨時表。(挺麻煩的。)
2,在in 字句 中 再用一層select 查詢封裝a表
update from a表 where id in( select id from (select id from a表 where ......) a1)