I have this table:
-----------------------
summonerId | timestamp
-----------------------
253222 | 14395235091096
929112 | 14395235091056
(...)
I want to update the row with the lower timestamp but I can't, when I do this
UPDATE summoners_shell
SET
summonerId = ".$s.",
timestamp = ".$time."
WHERE timestamp = (SELECT MIN(timestamp))
It updates all rows! Why? How do I do what I want?
When SELECT
-subquery is in WHERE
-clause, it locks the table so an update can not pass.
Just use JOIN
instead
UPDATE summoners_shell AS s1
JOIN (SELECT MIN(timestamp) AS mt FROM summoners_shell) AS mt ON (s1.timestamp = mt.mt)
SET
summonerId = ".$s.",
timestamp = ".$time."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With