MySQL , How to Select by rand() and update colums in same query? -
i need way select row rand() , update @ same query on mysql tried code did not answer:
set autocommit=0; begin transaction; select * articles status = 3 , name not null order rand() limit 0,1; update articles set status = 4 ; commit transaction;
this worked me:
update articles set `status` = 4 id in ( select id ( select id articles status = 3 , name not null order rand() limit 0,1 ) tmp );
mysql select sql-update
No comments:
Post a Comment