Re: [GENERAL] UPDATE .. JOIN?

2013-04-11 Thread ledwabakg
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

Re: [GENERAL] UPDATE .. JOIN?

2013-04-11 Thread ledwabakg
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

[GENERAL] Update Join Query

2008-06-23 Thread Daniel Futerman
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

Re: [GENERAL] Update Join Query

2008-06-23 Thread Mark Roberts
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 :

Re: [GENERAL] Update Join Query

2008-06-23 Thread Antonio Perez
--- 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

Re: [GENERAL] Update Join Query

2008-06-23 Thread Antonio Perez
--- 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

Re: [GENERAL] Update Join Query

2008-06-23 Thread Craig Ringer
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

[GENERAL] Update Join ?

2008-04-01 Thread kevin kempter
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

Re: [GENERAL] Update Join ?

2008-04-01 Thread Adam Rich
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

[GENERAL] UPDATE .. JOIN?

2008-01-12 Thread Sergei Shelukhin
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

Re: [GENERAL] UPDATE .. JOIN?

2008-01-12 Thread Rodrigo E. De León Plicet
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

Re: [GENERAL] UPDATE .. JOIN?

2008-01-12 Thread Sergei Shelukhin
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

Re: [GENERAL] UPDATE .. JOIN?

2008-01-12 Thread Rodrigo E. De León Plicet
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

Re: [GENERAL] UPDATE .. JOIN?

2008-01-12 Thread Rodrigo E. De León Plicet
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