ユーザ用ツール

サイト用ツール


02_freebsd:04_database:01_mysql:11_error_1093
no way to compare when less than two revisions

差分

このページの2つのバージョン間の差分を表示します。


02_freebsd:04_database:01_mysql:11_error_1093 [2015/03/27 08:57] (現在) – 作成 matsui
行 1: 行 1:
 +====== 11 ERROR:1093を回避 ======
  
 +update の時同じテーブルに対するサブクエリからの操作ができない
 +
 +<code console>
 +update hoge set code = 0
 +where id IN 
 +(select id from hoge as tmp where id = 1 group by id  order by id)
 +;
 +
 +ERROR 1093 (HY000): You can't specify target table 'hoge' for update in FROM clause
 +</code>
 +
 +
 +===== 対応 =====
 +
 +これで上手くいく
 +<code console>
 +update hoge set code = 0
 +where id IN (
 +select id from 
 +(select id from hoge where id = 1 group by id  order by id) as tmp
 +)
 +;
 +</code>
02_freebsd/04_database/01_mysql/11_error_1093.txt · 最終更新: 2015/03/27 08:57 by matsui