2012-04-03 10 views
1

複数のレコードを一度に削除したい。データベーステーブルのレコードをバッチ削除する

私は2つのテーブル、私はコメントをテーブルにAUTHOR_ID = 1 news_commentsからすべてのレコードを削除したい

comments: comment_id, comment, author_id 
news_comments: news_id, comment_id 

が含まれているものを持っています。

私はこれをやってみましたが、それは私に複数の項目を返すサブクエリに関するエラーが発生しました:

delete from news_items where comment_id = 
(select comment_id from comments where author_id = 1) 

答えて

5
delete from news_items where comment_id IN 
(select comment_id from comments where author_id = 1) 
             ^^ 
             IN 
2

この

delete from news_items where comment_id in 
(select comment_id from comments where author_id = 1) 
を試してみてください
関連する問題