If you wish to use an increment based on subset of a table you may combine UPDATE with Variables:e.g.
(This is because the order in which the rows are updated determines which rows are ignored.) Such statements produce a warning in the error log when using statement-based mode and are written to the binary log using the row-based format when using mode.
(Bug #11758262, Bug #50439) See Section 220.127.116.11, “Determination of Safe and Unsafe Statements in Binary Logging”, for more information.
In Java JDBC the Result Set interface includes support for updating the current row if the statement was created with Result Set. You should investigate whether Connector/C supports updateable resultsets.
EDIT: To update a row you will need to use a Prepared Statement containing an SQL UPDATE, and then the statement's execute Update() method.
You could then do select @value;in order to see what the value was before you updated it My SQL uses Watcom (Oracle) syntax for UPDATE, so it's possible to write something like:update Table1 t1 join Table2 t2 on t1. When done, you "clear" the semaphore by UPDATE table SET value = 0 WHERE name = 'name' The assumption is that the UPDATE is "atomic" in that no concurrent access by another process can occur between testing and setting the value field.