From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Need help with update |
Date: | 2010-02-24 09:15:23 |
Message-ID: | 20100224091523.GI22249@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
In response to A B :
> Hello.
> My SQL is a little rusty,
>
> With these tables (where id is unique)
>
> Table Y:
> a | id
> ----+---
> 10 | 1
> 20 | 2
> 30 | 3
>
> Table X:
>
> a | id
> ---+---
> 1 | 1
> 2 | 2
> 3 | 3
>
> Now I want to update each row in the Y table and set the a value to
> the corresponding a value that is found in the X table, matched on the
> id.
>
> This means that in the end, the Y table should contain the same
> values as the X table in this case.
update y set a=x.a from x where y.id=x.id;
HTH, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99
From | Date | Subject | |
---|---|---|---|
Next Message | Jasen Betts | 2010-02-24 10:45:07 | Re: Seeking experiences 'accessing' Microsoft Active Directory credentials from PostgreSQL, in conjunction with the sys admin / IT... |
Previous Message | A B | 2010-02-24 09:09:36 | Need help with update |