update websites set master = 2 where url = select url from websites where id = 12;
に更新のターゲット表を指定することはできません。は、どのように私はこのクエリを書き直すことができます:あなたはどうやらmysqlは、あなたが更新しているテーブルの上に、選択クエリを実行することはできませんFROM句
update websites set master = 2 where url = select url from websites where id = 12;
に更新のターゲット表を指定することはできません。は、どのように私はこのクエリを書き直すことができます:あなたはどうやらmysqlは、あなたが更新しているテーブルの上に、選択クエリを実行することはできませんFROM句
派生テーブルに入れます。 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);
いいえ、それはだまされません。 – HyderA
k、どのように ウェブサイトw2、w2.master = 2を設定すると、ウェブサイトを更新します.w.url = w2.url、w2.id = 12); –
これはなぜ動作しないのですか? –
それは馬鹿だ!ありがとう! – HyderA
解決策を提供するための+1 *と*ドキュメント! –