Why does 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?
LIMITis not supported only for usingIN(replaced with backticks ~ drachenstern)– tomas.lang Feb 21 '11 at 14:05blocks.– Derek Downey Feb 21 '11 at 14:19