I'd like to do this.
update cart set productname='hey' where cartid=(select max(cartid) from cart)
In MySQL, you can use
update cart set productname = 'hey' order by id desc limit 1;
You can review the documentation here.
If you want to calculate the value, you can use a
update cart c join (select max(id) as maxid from card) cc on c.id = cc.maxid set productname = 'hey';
This would be particular useful if multiple rows could have the maximum id and you wanted all to be updated.