By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table testTable(st_id int, sbj_id int, description varchar(50), scr float, sbm_dt datetime);
insert into testTable values(2001, 10, 'Q2', 7.4, '2021-05-03 17:03:32');
insert into testTable values(2001, 10, 'Q1', 8.0, '2021-04-03 18:07:35');
insert into testTable values(2011, 10, 'Q1', 5.0, '2021-04-03 19:07:35');
insert into testTable values(2001, 10, 'Q2', 7.4, '2021-05-03 17:03:32');
update testTable set st_id=2011 where st_id=2001 order by sbm_dt desc limit 1
select * from testTable
st_id | sbj_id | description | scr | sbm_dt |
---|---|---|---|---|
2011 | 10 | Q2 | 7.4 | 2021-05-03 17:03:32 |
2001 | 10 | Q1 | 8 | 2021-04-03 18:07:35 |
2011 | 10 | Q1 | 5 | 2021-04-03 19:07:35 |
2001 | 10 | Q2 | 7.4 | 2021-05-03 17:03:32 |