0

这是我的 mysql 查询,但它不起作用

update  jos_users set name =
(SELECT name 
FROM jos_users
WHERE id = 478) where id =477

谁能告诉如何执行这个查询?或其他可能性?

4

1 回答 1

1

你应该得到的错误信息是:

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

这意味着您不能在子选择中使用要更新的同一个表。无论如何,有一个小解决方法可以避免这种情况:只需使用嵌套的子选择:

update
  jos_users
set
  name = (select name from
            (SELECT name FROM jos_users WHERE id = 478)
               AS subselect_value)
where
  id = 477
于 2012-07-31T05:16:14.890 回答