Re: simultaneous access of two tables

From: Chuck Hamilton <chuckh_at_ix.netcom.com>
Date: 1995/05/31
Message-ID: <3qhpsh$5b1_at_ixnews4.ix.netcom.com>#1/1


In <3qd4rh$si5_at_cs5.cs.ait.ac.th> b94327_at_cs.ait.ac.th (Miss Ma Jessica S Cocjin) writes:
>
>hello there...
> can anybody help me?
>
> i have two tables (t1 and t2), i want to update t1 with the
 values
>of t2, take note: not all records in t1 are in t2.
>
> have tried using declare... open.. fetch but it seems it does not
 work.
>any suggestions are greatly appreciated by me...

Why not just use an SQL UPDATE command?

UPDATE t1 SET colname =

    (SELECT colname FROM t2 WHERE t2.key = t1.key)     WHERE EXISTS (SELECT * FROM t2 WHERE t2.key = t1.key)

This assumes you only want to update the records in t1 that have a corresponding record in t2. You didn't specify what you wanted to do (if anything) with the remaining records in t2.

-- 
Chuck Hamilton
chuckh_at_ix.netcom.com

Never share a foxhole with anyone braver than yourself!
Received on Wed May 31 1995 - 00:00:00 CEST

Original text of this message