I got the following table, it is a queue table in which actions are stored (the DB engine of this table is InnoDB).
These actions are picked up my multible servers using diffrent database connection, eatch server will have its own server_id.

The table actions has the following fields:
+----------+----+----------+------+
| action_id|lock|server_id|action|
+----------+----+----------+------+

Example contents:
|1| 0 |null|bla1 |
+-+-+----+----+
|2| 0 |null|bla2 |
+-+-+----+----+
|3| 0 |null|bla3 |
+-+-+----+----+
|4| 0 |null|bla4 |
+-+-+----+----+

The servers will constantly pull actions from this table and execute them, but the main problem I am trying to prevent is that diffrent servers execute the same action (which will screw up the end result).

I need to write a solid mySQL transaction to prevent servers from picking up the same action.

I have never worked with Transactions in MySQL, I read some stuff about it but I can't really make sence of it.

I though about the problem and came up with a query something like this:
UPDATE actions SET server_id=$server_id WHERE action_id = (SELECT MIN(action_id) FROM actions WHERE sevrer_id IS NULL AND lock = 0) limit 1;
SELECT action FROM actions WHERE server_id = $server_id and lock=0;
Commit;
update actions set lock=1 where action_id = $action_id

I am sure there is an easier way or better way to solve this problem, so thats why I am posting here.
I really lost on this problem, so any help would be greatly apriciated!

Sorry for my crappy english and thanks in advance!