Menu

Mysql Select for update

Help
eric
2013-02-01
2013-02-10
  • eric

    eric - 2013-02-01

    Hello

    Is there a way to perform this kind of request in one [database] block?

    set @a = (SELECT id FROM Name where (locked= 0) Limit 1,1);
    select id,Name FROM Name Where id = @a for update;
    update Name Set locked = 1 Where id = @a;

    If not how can I read a record in mysql and be sure that it is not treated by an other process at the same time ?

    Thanks

     
  • eric

    eric - 2013-02-10

    I solved it in 3 requests and it works, even if ther is various access to the database at the same time.

     

Log in to post a comment.