エラー 1093 は、サブクエリが削除元のテーブルをクエリする場合、サブクエリを使用して UPDATE または DELETE できないことを示しています。
だからあなたはできません
delete from table1 where id in (select something from table1 where condition) ;
わかりました、その制限を回避する最善の方法は何ですか?
編集:
興味のある人への質問は次のとおりです。
mysql> desc adjacencies ; +--------+---------+------+-----+---------+------ -+ | | フィールド | フィールド タイプ | ヌル | キー | キー | デフォルト | エクストラ | +--------+---------+------+-----+---------+------ -+ | | 親| int(11) | いいえ | PRI | ヌル | | | | | 子 | int(11) | いいえ | PRI | ヌル | | | | | パスレン | int(11) | いいえ | | | ヌル | | | +--------+---------+------+-----+---------+------ -+ -- クエリは -- すべての子供たちにそう言いなさい -- 私の年老いた両親のことを考えるのをやめる -- まだ両親です 隣接から削除 親がいる場所 ( -- すべての私の両親、祖父母 親を選択 隣接から ここで child=@me and parent!=@me ) -- 私の関係だけに関係する -- 祖父母 私の子供が心配している場所 と子 ( -- すべての子を取得します 子を選択 隣接から ここで、parent=@me ) ;
だから私がこれまでに試したことは、という一時テーブルを作成することですadjsToDelete
create temporary table adjsToRemove( parent int, child int ) ;
insert into adjsToRemove...
これで、削除するリレーションのコレクションができました。ここで、親/子のペアはそれぞれ、削除する行を一意に識別します。しかし、隣接テーブルから各ペアを削除するにはどうすればよいでしょうか?
の各エントリに一意のauto_increment
ed キーを追加する必要があるようですが、そうadjacencies
ですか?