I have a MySQL table of tasks to perform, each row having parameters for a single task. There are many worker apps (possibly on different machines), performing tasks in
UPDATE tasks SET guid = %d, params = @params := params WHERE guid = 0 LIMIT 1;
It will return 1 or 0, depending on whether the values were effectively changed.
SELECT @params AS params;
This one just selects the variable from the connection.
From: here