Update table based on self table lookup in redshift

后端 未结 2 941
春和景丽
春和景丽 2021-01-28 17:25

I have the below table,

id   email   mgr_email   mgr_id
-------------------------------
1    email1   email2    
2    email2   email3
3    email3   email4
         


        
2条回答
  •  半阙折子戏
    2021-01-28 17:56

    Use sub query for self join:

    Try this:

    update mytable 
        set mgr_id=t2.id 
        from (select id, email from mytable) t2 
        where mytable.mgr_email=t2.email
    

提交回复
热议问题