mysql - Error Code: 1093. You can't specify target table

UPDATE card SET value = (SELECT value FROM card WHERE id = 23) WHERE id = 20;

更新时 在where条件里面加入的子查询导致的。

解决方法:

 UPDATE card SET value = (SELECT val FROM (SELECT value as val FROM card WHERE id = 23)  as temp )WHERE id = 20;
使用临时表。

posted @ 2014-10-14 14:12  廖东海  阅读(312)  评论(0编辑  收藏  举报