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
Replace the tables on this query with your 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
Hi,
Looking for the correct syntax for an UPDATE LEFT JOIN query in PostgreSQL.
The equivalent MySQL query is :
UPDATE
Foo f LEFT JOIN Goo g on f.Foo_ID = g.Goo_ID
SET
f.Foo_ID = g.Goo_ID
WHERE
f.Foo_ID IS NOT NULL;
When I try to run this in Postgres, i
update foo
set foo_id = g.goo_id
from goo g
where foo.foo_id = g.goo_id and foo.foo_id is not null
I think. :)
-Mark
On Mon, 2008-06-23 at 21:43 +0200, Daniel Futerman wrote:
Hi,
Looking for the correct syntax for an UPDATE LEFT JOIN query in
PostgreSQL.
The equivalent MySQL query is :
--- El lun 23-jun-08, Daniel Futerman [EMAIL PROTECTED] escribió:
De: Daniel Futerman [EMAIL PROTECTED]
Asunto: [GENERAL] Update Join Query
A: pgsql-general@postgresql.org
Fecha: lunes, 23 junio, 2008, 4:43 pm
Hi,
Looking for the correct syntax for an UPDATE LEFT JOIN query in PostgreSQL
--- El lun 23-jun-08, Daniel Futerman [EMAIL PROTECTED] escribió:
De: Daniel Futerman [EMAIL PROTECTED]
Asunto: [GENERAL] Update Join Query
A: pgsql-general@postgresql.org
Fecha: lunes, 23 junio, 2008, 4:43 pm
Hi,
Looking for the correct syntax for an UPDATE LEFT JOIN query in PostgreSQL
Daniel Futerman wrote:
Is it possible to have UPDATE JOIN queries in PostgreSQL?
Yes:
UPDATE target
FROM othertable;
As far as I know Pg can only do an inner join on the update target. This
can be easily be turned into an outer join with something like:
UPDATE target
Hi List;
Does Postgres allow updates based on the context of a sub-query,
something like the sample below ?
1) Insert data (real_tab.keyID and real_tab.data_desc) into a temp
table (temp_tab)
2) update real_tab
set real_tab.data_desc = temp_tab.data_desc
join real_tab on
Does Postgres allow updates based on the context of a sub-query,
something like the sample below ?
Yes,
Update real_tab
set real_tab.data_desc = temp_tab.data_desc
From temp_tab
Where real_tab.keyID = temp_tab.keyID
(don't repeat your updated table in the from list unless you
Mean to
Hi.
I was wondering if I could do something similar to this in Postgres and
if yes how?
UPDATE table1 SET blah = 1 FROM table1
INNER JOIN table2 ON table1.id = table2.t1id
If not, is there any way to make UPDATE ... WHERE id IN () use indexes?
---(end of
On Jan 12, 2008 5:22 PM, Sergei Shelukhin [EMAIL PROTECTED] wrote:
Hi.
I was wondering if I could do something similar to this in Postgres and
if yes how?
UPDATE table1 SET blah = 1 FROM table1
INNER JOIN table2 ON table1.id = table2.t1id
UPDATE table1 t1
SET blah = 1
FROM table2 t2
Rodrigo E. De León Plicet wrote:
On Jan 12, 2008 5:22 PM, Sergei Shelukhin [EMAIL PROTECTED] wrote:
Hi.
I was wondering if I could do something similar to this in Postgres and
if yes how?
UPDATE table1 SET blah = 1 FROM table1
INNER JOIN table2 ON table1.id = table2.t1id
UPDATE
On Jan 13, 2008 12:05 AM, I said
It's all in the docs:
http://www.postgresql.org/docs/8.2/static/sql-update.html
To clarify, you can use the direct form, without using a subselect:
UPDATE table1 t1
SET blah = 1
FROM table2 t2
JOIN table3 t3
ON t2.id = t3.t2id
WHERE t1.id = t2.t1id
Lookup
On Jan 12, 2008 11:26 PM, Sergei Shelukhin [EMAIL PROTECTED] wrote:
Hmmm. What if there's more than one table? Is from x,y a viable option?
UPDATE table1 t1
SET blah = 1
FROM (
SELECT t2.t1id
FROM table2 t2
JOIN table3 t3
ON t2.id = t3.t2id
) foobar
WHERE t1.id = foobar.t1id
It's all in
14 matches
Mail list logo