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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -