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개 / 댓글 2개
채택된 답변
+20 포인트
2018-08-23 (목) 17:59:28
파일중에 test테이블에 글내용이 test.com이 존재하는 파일만 추출
Copy
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
약간 확장
Copy
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이 존재하는 파일만 삭제
Copy
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)
2018-08-23 (목) 17:21:39
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%';
별문제가 없어 보이는데요. 어떤 에러가 나오는지요?
답변에 대한 댓글 2개
2018-08-23 (목) 17:43:41
2018-08-23 (목) 17:58:27
DELETE f
FROM g5_board_file as f
INNER JOIN g5_write_test as t ON t.wr_id=f.wr_id AND f.bo_table='test'
WHERE t.wr_content like '%test.com%';
AND f.bo_table='test' 게시판명이 test인것중에 wr_id가 같은것을 찾아 삭제하면 안될까요?
FROM g5_board_file as f
INNER JOIN g5_write_test as t ON t.wr_id=f.wr_id AND f.bo_table='test'
WHERE t.wr_content like '%test.com%';
AND f.bo_table='test' 게시판명이 test인것중에 wr_id가 같은것을 찾아 삭제하면 안될까요?
답변을 작성하려면 로그인이 필요합니다.
제가 원하는것만 삭제되는게아니라
에러는 아니고 다른게시판 wr_id 까지 삭제되더라고요
g5_board_file 중에 다른 bo_table
그러니까 g5_board_file 다른게시판 g5_write_test2 의 동일한 wr_id 도 삭제되더라고요