Mysql Update and Select first element -
i use 2 requests :
select `user` `table1` order `last activity` asc limit 0,1;
and
update `table1` set `last activity` = current_timestamp `user` = 'user'
i join both in 1 request.. because 2 program take same user.
edit: forgot need user name, update first element not enough. take user last activity, update time, , program user. problem many programs running simultaneously. , important not access same user @ same time between 2 requests
it sounds looking subquery.
that this:
update `table1` set `last activity` = current_timestamp `user` = (select `user` `table1` order `last activity` asc limit 0,1)
Comments
Post a Comment