Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update via sql or spl?

Status
Not open for further replies.

axo959

Technical User
Dec 2, 2002
2
US
Hello all-

I'm trying to perform an update. I've been reading through the manual on SPLs and cant piece it together. I have two tables (t1 & t2) with columns as follows:

t1
**
cust_id
date

t2
**
cust_id
fld02

I'd like to set t2.fld02 to 'Y' if t1.date is not null
I'd like to set t2.fld02 to 'N' if t1.date is null

I'm not sure how to loop through every customer in the t2 table and perform an if-then statement to set fld02 to a Y or N.

thanks for any suggestions,
Chris
 
In SQL:
Code:
UPDATE t2 SET fld02='Y' WHERE cust_id IN(SELECT cust_id FROM t1 WHERE date IS NOT NULL);
UPDATE t2 SET fld02='N' WHERE cust_id IN(SELECT cust_id FROM t1 WHERE date IS NULL);

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top