1. 程式人生 > >mysql update in 巢狀子查詢更新

mysql update in 巢狀子查詢更新

更新該句

update punchcard_tbl

set percheck=3

where id in (select id punchcard where id=1)

在 MySQL 命令列工具中傳回:
ERROR 1093 (HY000): You can't specify target table 'forum_members' for update in FROM clause

改成下列語句就可以解決無法更新的問題

update punchcard_tbl a

inner join punchcard_tbl b on b.id=1 and a.id=b.id

set a.percheck=3