如何在postgresql

时间:2017-03-28 11:49:47

标签: postgresql

UPDATE patient 
SET p.patient_name='Keerthi',
c.pat_cnt_pincode=560765
FROM patient as p 
        left JOIN patient_contact AS c on c.pat_cnt_email_id=p.patient_email 
        WHERE   p.patient_id=921;

1 个答案:

答案 0 :(得分:0)

您只能在一个语句中更新一个表。但是,你可以这样做:

with p as (
      update patient p
          set patient_name = 'Keerthi'
          where p.patient_id = 921
      returning *
     )
update patient_contact pc
    set pat_cnt_pincode = 560765
    from p
    where pc.pat_cnt_email_id = p.patient_email;