From: | ledwabakg <kgauledwaba7(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: UPDATE .. JOIN? |
Date: | 2013-04-11 15:06:01 |
Message-ID: | 1365692761638-5751783.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Re: Updating a table with joins
I have been trying to achieve the same thing for quite a period of months
but
could not get the right query, finally now i am sorted, this one works like
a charm for me.
========================================
Replace the tables on this query with joined tables
Update service_reminderschedule srs
set reminder_sent = false
from (
select ss.fk_man_service_id, ss.serviceschedule_id, v.vehicle_id
from serviceschedule ss
inner join manufactureservices ms
on ms.man_service_id = ss.fk_man_service_id
inner join vehicle_model vm
on vm.model_id = ms.fk_vehicle_model_id
inner join vehicle_info v
on v.fk_vehicle_model_id = vm.model_id
where ms.fk_vehicle_model_id = 1) ss
where ss.vehicle_id = srs.fk_vehicle_id
and srs.fk_serviceschedule_id = ss.serviceschedule_id and srs.date_sent is
null;
--
View this message in context: http://postgresql.1045698.n5.nabble.com/UPDATE-JOIN-tp1895125p5751783.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-04-11 15:12:25 | Re: Cost of initiating cursors |
Previous Message | David Greco | 2013-04-11 14:51:37 | Streaming Replication 9.2 |