게시글을 백업하는데.. 쿼리 관련해서 문의드립니다. (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개 / 댓글 3개
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)
답변에 대한 댓글 2개
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);
delete from g5_write_abc where wr_id in ( select wr_id from temp);
쿼리문이 잘못된거 같습니다.
delete 문 이하 작성해주셔야 답변 가능합니다.
답변에 대한 댓글 1개
그래서 delete 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)
);
이렇게 해서 오류가 난 부분입니다.
답변을 작성하려면 로그인이 필요합니다.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'in (select wr_id from (select wr_id from g5_write_abc where wr_parent in ' at line 1
sytnax 에러라는데~!! 어렵군요