simple 4gl programme
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
pple i am having problem s or may be i am tied because i have been working the whole night problem i have two tables and what i want is to take a unique value(column) from table 2 and put it in table 1 example table one name regno course simba 34 ff arts 35 tt iwe 23 dd table two name regno course simba 34 aa arts 35 mm iwe 23 dd so i want a script that will run for three thousand records and update course to a value in table2 eg course in table one to aa ie basically copying column course in table two to table one -----Original Message----- From: Art S. Kagel [mailto:kagel@bloomberg.net] Sent: Wednesday, November 29, 2000 12:28 AM To: informix-list@iiug.org Subject: Re: TIMESTAMP data type? Richard harnden wrote: > > >>> "Obnoxio The Clown" <obnoxio@hotmail.com> 11/23 10:27 am >>> > > > >Well, why not create your own TIMESTAMP datatype, since you're using 9.20? > > > >Then you won't have to CHANGE YOUR CODE! :-) > > But, you can't create a distinct type with a default clause, can you? Don't need a default clause if the type is designed to insert a time stamp automatically. Art S. Kagel
update table1 set
course = (select table2.course
from table2
where table1.regno = table2.regno)
where exists (
select 1 from table2
where table1.regno = table2.regno);
Note the following :
1. Assumes that a unique constraint exists on table2.regno. If, instead, a
unique key exists on name, use name in place of regno. If no unique key
exists on table2, the select must be modifed to return exactly one value
using an aggregate like min(table2.course) or max, etc.
2. The "where exists" clause ensures that table1 rows, that do not have
table2 matches, do not get set to null.
Rudy
Simbarashe.Pangeti@icl.com wrote:
> problem
>
> i have two tables and what i want is to take a unique value(column) from
> table 2 and put it in
> table 1
>
> table one
> name regno course
> simba 34 ff
> arts 35 tt
> iwe 23 dd
>
> table two
> name regno course
> simba 34 aa
> arts 35 mm
> iwe 23 dd
>
> so i want a script that will run for three thousand records and update
> course
> to a value in table2 eg course in table one to aa ie basically copying
> column course in table two to table one
>