Why this query DELETE FROM test WHERE id=(SELECT id FROM (SELECT * FROM test) temp ORDER BY RAND() LIMIT 1);
sometimes delete 1 row, sometimes 2 rows and sometimes nothing?
If I write it in this form: SET @var = (SELECT id FROM (SELECT * FROM test) temp ORDER BY RAND() LIMIT 1); DELETE FROM test WHERE id=@var;
, then it work correctly - is problem in subquery?