Re: help with update sql

From: Ed prochak <ed.prochak_at_magicinterface.com>
Date: 20 Aug 2003 08:47:14 -0700
Message-ID: <4b5394b2.0308200747.54b30f01_at_posting.google.com>


"Whocares" <reply_at_the_group.com> wrote in message news:<Tir0b.15135$os2.215309_at_news2.e.nsc.no>...
> Hi,
>
> I think it should be an easy sql but I'm stuck and I could use some help
> here ...
>
> Table:
>
> U1 U2 Ref Gro
> 1 1 1 1
> 2 2 2 1
> 1 1 3 1
> a a 1 2
> b c 2 2
> c a 3 2
>
> I want to update the U1 and U2 columns where Ref>1 with the values from the
> row where Ref=1 but grouped by Gro - eg wanted result:
>
> U1 U2 Ref Gro
> 1 1 1 1
> 1 1 2 1
> 1 1 3 1
> a a 1 2
> a a 2 2
> a a 3 2
>
>
> TIA,
> Zsolt

To begin, try making the select that pulls out the values that you want. IOW,
complete the SQL statement:
SELECT U1, U2 from table ...
so that it returns
> U1 U2
> 1 1
> a a

Then write a correlated query that joins the result you want to the records you want to update.

When you have a query that can select the right rows, then you can advance to making the update statement.

If you have problems on the way, post your SQL code and we can help. Received on Wed Aug 20 2003 - 17:47:14 CEST

Original text of this message