SELECT FOR UPDATE MYSQL

0

I have a simple query that I execute in mysql with phpmyadmin :

select * from tabla for udpate ;

But I get an error "an expression was expected" . I can not realize what is missing. Thanks!

    
asked by Martin 11.08.2018 в 00:17
source

1 answer

0

If you use FOR UPDATE with a storage engine that uses page or row locks, the rows examined by the query are locked against writing to the end of the current transaction.

SELECT ... TO UPDATE acquires write locks on the objects (rows, pages, depending on the engine). This implies a bit of overload. In addition, the database (the InnoDB engine in most cases) needs to do additional accounting for the control of multiple versions (MVCC).

See the documentation for MySQL in select ... for update for detailed information and examples

Also I'm noticing that your query has syntax errors:

   SELECT * FROM posiciones WHERE Id_torneo = 161 FOR LIMIT 0, 25

It should be:

  SELECT * FROM posiciones WHERE Id_torneo = 161 FOR UPDATE

SOLUTION You must remove the LIMIT in the configuration of your engine, that is why you have the problem when executing your query.

    
answered by 11.08.2018 в 00:24