delete 에서 inner join 수정좀 부탁합니다
본문
g5_write_test 게시판에
wr_content 내용에 test.com 포함되는
g5_board_file 의 wr_id 만 삭제하고싶습니다
밑에 잘못됬는데 어떻게 고침 되나요?
delete f from g5_board_file as f inner join g5_write_test as t on f.wr_id=t.wr_id where t.wr_content like '%test.com%';
답변 2
파일중에 test테이블에 글내용이 test.com이 존재하는 파일만 추출
select a.* from g5_board_file a, g5_write_test b
where a.bo_table = 'test'
and b.wr_content like '%test.com%'
and b.wr_id = a.wr_id
약간 확장
select * from g5_board_file x
where exists(
select 'x' from g5_board_file a, g5_write_test b
where a.bo_table = 'test'
and b.wr_content like '%test.com%'
and b.wr_id = a.wr_id
and a.bo_table = x.bo_table
and a.wr_id = x.wr_id
and a.bf_no = x.bf_no)
확장쿼릴 이용해서 삭제 적용
파일중에 test테이블에 글내용이 test.com이 존재하는 파일만 삭제
delete from g5_board_file x
where exists(
select 'x' from g5_board_file a, g5_write_test b
where a.bo_table = 'test'
and b.wr_content like '%test.com%'
and b.wr_id = a.wr_id
and a.bo_table = x.bo_table
and a.wr_id = x.wr_id
and a.bf_no = x.bf_no)
DELETE f
FROM g5_board_file as f
INNER JOIN g5_write_test as t ON t.wr_id=f.wr_id
WHERE t.wr_content like '%test.com%';
별문제가 없어 보이는데요. 어떤 에러가 나오는지요?
답변을 작성하시기 전에 로그인 해주세요.