티스토리 뷰

delete from a_table

where a_table.col1 in (select a_table.col1

from a_table

where a_table.col2 = true)


* 이렇게 자기가 DML 을 진행할 table을 조건으로 사용하기위해 select 해서 가져올경우 에러가 발생한다


You can't specify target table 'a_table' for update in FROM clause 


* 그럴땐 select 를 다시 서브쿼리 처리하면된다(고한다)


delete from a_table

where a_table.col1 in (select alias_name.col1

from (select a_table.col1

from a_table

where a_table.col2 = true) as alias_name


* 추가로 alias 로 group 을 지정하려했는데 에러가 발생했다 약속값인가보다

* 테이블을 변형하다보니 이상한부분이 있는데 이론상 크게 벗어나지 않으니 참고하면 좋을듯

* 참고 http://darky.egloos.com/2378550


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함