Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Update with condition
What is the relationship between the two tables?
Also, many values in T2.F3 could be greater than T1.F3. Do you want the
first one? last one?
I would start with this template and then, after you see what I'm doing,
change it to what you need.
update T1
set F1 = (select min(T2.F1) from T2 where T1.F3 > T2.F3);
This will update T1 and set T1.F1 to the first T2.F1 value where T1.F3 is greater than T2.F3. It sounds confusing, but I don't have the specifics ... so ...
"gil guerillot" <gil.guerillot_at_ratp.fr> wrote in message
news:3B8BAEBB.5E866007_at_ratp.fr...
> I have 2 tables with 3 fields
>
> T1
>
> F1
> F2
> F3
>
>
> T2
>
> F1
> F2
> F3
>
> the common key is F1
> i want to update T1.F1 with the value of T2.F1
>
> but only when T1.F3 > T2.F3
>
> how can i do simply (SQL) wihtout PL/SQL ?
>
> thanks
>
Received on Tue Aug 28 2001 - 17:24:55 CDT
![]() |
![]() |