카테고리 없음

[SQL] 부분적으로 중복 된 행의 테이블 업데이트

행복을전해요 2021. 2. 6. 08:50

행을 자신에 결합하지 않는 조건을 추가 할 수 있습니다 (항상 참). 예 :

update mytable t1 set indicator = 0
where exists (
          select 1
                    from mytable t2
                              where t2.day = t1.day
                                        and t1.company <> t2.company
                                                  and t2.industry = t1.industry
                                                            and t2.indicator <> 0
                                                                      and t1.indicator <> 0)
                                                                      


출처
https://stackoverflow.com/questions/22050180