Re: Update from select

From: Bret Stern <bret_stern(at)machinemanagement(dot)com>
To: Justin Tocci <justin(at)workflowproducts(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update from select
Date: 2013-05-14 04:53:28
Message-ID: 1368507208.3693.17.camel@centos-dev.machinemanagement.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Easy money indeed. Thanks for the help
On Mon, 2013-05-13 at 15:28 -0500, Justin Tocci wrote:
> em stands for "easy money"
>
> update tbl1
> set col3=em.col3,col4=em.col4,col5=em.col5
> from
> (select col3, col4,col5 from tbl2 where col1="criteria") em
>
> Regards,
>
> Justin Tocci
> Programmer
> www.workflowproducts.com
> 7813 Harwood Road
> North Richland Hills, TX 76180
> phone 817-503-9545
> skype justintocci
>
> On May 13, 2013, at 3:23 PM, Bret Stern <bret_stern(at)machinemanagement(dot)com> wrote:
>
> > PG 8.4
> >
> > Having trouble putting together an update query to update
> > multiple columns in tbl1 from columns in tbl2.
> >
> > update tbl1
> > set col3,col4,col5
> > from
> > (select col3, col4,col5 from tbl2 where col1="criteria")
> >
> >
> >
> > Can someone add to the Postgres Docs (shown below) to help me with this.
> >
> > UPDATE employees SET sales_count = sales_count + 1 WHERE id =
> > (SELECT sales_person FROM accounts WHERE name = 'Acme Corporation');
> >
> >
> > Many thanks
> >
> > Bret Stern
> >
> >
> >
> > --
> > Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2013-05-14 05:29:20 Re: postgres and xquery
Previous Message kristian kvilekval 2013-05-14 04:31:11 postgres and xquery