2012-04-03 2 views
1

한 번에 여러 레코드를 삭제하고 싶습니다.데이터베이스 테이블의 일괄 삭제 레코드

나는 내가 news_comments에서 모든 기록을 삭제하려면

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

을 포함 두 테이블, 하나가 어디 author_id 코멘트 테이블 = 1.

나는이 일을 시도하지만, 나에게 하나 개 이상의 항목을 반환하는 서브 쿼리에 대한 오류를 준 :

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) 
시도
관련 문제