게시글을 백업하는데.. 쿼리 관련해서 문의드립니다. (select는 나오는데 delete 시 오류)
본문
다중 서브 쿼리를 이용해서,
일단
select * from g5_write_abc
where wr_id in
(select wr_id from g5_write_abc where wr_parent in
(select wr_id from g5_write_abc where wr_1 =2 and wr_is_comment =0)
);
파란색의 조건 wr_1 =2이고 wr_is_comment =0 wr_id를 추출하여
wr_parent 댓글에 포함된것이 있는지 확인하여 그것만 추출하는 쿼리입니다.
이렇게 하면 정상적으로 쿼리가 나옵니다.
문제는 delete from g5_write_abc.... 이렇게 하면,
ERROR 1093 (HY000): You can't specify target table 'g5_write_abc' for update in FROM clause
어떻게 하면 될까요?
답변 2
delete from g5_write_abc where wr_id in (select wr_id from
(select wr_id from g5_write_abc where wr_parent in
(select wr_id from g5_write_abc where wr_1 =2 and wr_is_comment =0)) a)
쿼리문이 잘못된거 같습니다.
delete 문 이하 작성해주셔야 답변 가능합니다.
답변을 작성하시기 전에 로그인 해주세요.