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 statement - with two tables

Status
Not open for further replies.

gooseriver

IS-IT--Management
Aug 4, 2006
93
CA
I am trying to convert this to an update statement in which I want to update tb2.effdt = tb1.startdt where tb2.type = 'zenster' and tb2.effdt< tb1.startdt

select distinct *
from Table1 tb1, Table2 tb2
where tb1.id=tb2.id and tb2.type='zenster' and tb2.effdt< tb1.startdt;

I have tried multiple update statements but keep getting zero records updated.





 
Code:
update table2 tb2
set tb2.effdt = 
(select max(tb1.effdt)
 from table1 tb1
where tb2.effdt < tb1.startdt)
where tb2.type = 'zenster';

Bill
Lead Application Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top