티스토리 뷰
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