update websites set master = 2 where url = select url from websites where id = 12;
Apparently mysql won't allow you t开发者_运维技巧o run a select query on table you're updating.
Put it into a derived table. This gets materialised into a temp table and gets around the restriction.
update websites
set master = 2
where url in (select url
from (select url
from websites
where id = 12) t);
update websites set master = 2 where url in (select w2.url from websites w2 where w2.id = 12);
精彩评论