delete 에서 inner join 수정좀 부탁합니다

delete 에서 inner join 수정좀 부탁합니다

QA

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%';
 
별문제가 없어 보이는데요. 어떤 에러가 나오는지요?

답변 감사합니다
제가 원하는것만 삭제되는게아니라
에러는 아니고 다른게시판 wr_id 까지 삭제되더라고요

g5_board_file 중에 다른 bo_table
그러니까 g5_board_file  다른게시판 g5_write_test2 의 동일한 wr_id 도 삭제되더라고요

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가 같은것을 찾아 삭제하면 안될까요?

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT