whojoedaddy
Programmer
Hi, I have a sql query, but it seems rather long. Is there an easier way to do this?
update HISTORY set HS_CHANGER = 'bes' where HS_CHANGE_DATE = (select MAX(HS_CHANGE_DATE) from HISTORY where HS_KEY = 138) and HS_CHANGE_TIME = (select MAX(HS_CHANGE_TIME) from HISTORY where HS_KEY = 138 and HS_CHANGE_DATE = (select MAX(HS_CHANGE_DATE) from HISTORY where HS_KEY = 138)) and HS_KEY = 138
Basically I'm trying to change the value of a column for a particular HS_KEY when it's the newest row that's been changed (latest date/time).
update HISTORY set HS_CHANGER = 'bes' where HS_CHANGE_DATE = (select MAX(HS_CHANGE_DATE) from HISTORY where HS_KEY = 138) and HS_CHANGE_TIME = (select MAX(HS_CHANGE_TIME) from HISTORY where HS_KEY = 138 and HS_CHANGE_DATE = (select MAX(HS_CHANGE_DATE) from HISTORY where HS_KEY = 138)) and HS_KEY = 138
Basically I'm trying to change the value of a column for a particular HS_KEY when it's the newest row that's been changed (latest date/time).