Comments - SELECT

1 year, 8 months ago Tibor den Ouden

Is it possible to have select for update / lock in share mode to return no rows or an empty result set, but still lock all target records ? I use a select for update to reduce the occurrence of deadlocks but I am not interested in the returned result set. Would for instance select for update limit 0 lock all records which fulfill the conditions of the select statement but return no records ? Or is there another way to accomplish this ?

1 year, 8 months ago Markus Mäkelä

If you know your application is the only one that modifies the records, you could use GET_LOCK to cooperatively lock the table without actually locking it.

1 year, 8 months ago Sergei Golubchik

Try SELECT COUNT(*) FROM ... or an impossible HAVING clause

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.