Can I select and update together? Instead of use 2 queries, can I use just one?
SELECT data FROM log limit 1
update log SET `data` = $now where `id` = 1
any ideas?
Can I select and update together? Instead of use 2 queries, can I use just one?
SELECT data FROM log limit 1
update log SET `data` = $now where `id` = 1
any ideas?
Lock the table to prevent another user from updating the table.
LOCK TABLES data;
SELECT data FROM log WHERE id = 1;
// fetch the result
UPDATE log SET data = NOW() WHERE id = 1;
UNLOCK TABLES;