1

複数のレコードを一度に削除したい。

私は2つのテーブルを持っています。

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

コメントテーブルのauthor_id=1であるnews_commentsからすべてのレコードを削除したいと思います。

これを試してみましたが、サブクエリが複数のアイテムを返すというエラーが発生しました。

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

2 に答える 2

5
delete from news_items where comment_id IN 
(select comment_id from comments where author_id = 1)
                                        ^^
                                        IN
于 2012-04-03T20:11:17.530 に答える
2

これを試して

delete from news_items where comment_id in 
(select comment_id from comments where author_id = 1)
于 2012-04-03T20:11:42.413 に答える