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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Question

Status
Not open for further replies.

mark1110

Programmer
Apr 20, 2005
85
US
Hi

I am updating a table and I am not sure update it based on a condition. I am using Sybase 11.92

I want to update from table1 to table2. Table1 has a field called term, it is either a Y or N. Table1 also has a term_date field. Table2 has two date fields, term1 and term2. I want to update term1 or term 2 on table2 with term_date from table1 based on whether term is a Y or N.

if term = Y
update term1 with term_date
end if

if term = N
update term2 with term_date
end if

I can't for the life of me figure out how to do this. Can anyone help?


Thanks,

Mark
 
update t2
set term1=termdate
from t1, t2
where t1.id=t2.id
and t1.term='Y'

update t2
set term2=termdate
from t1, t2
where t1.id=t2.id
and t1.term='N'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top