When running the following query:
SELECT productid
FROM product
WHERE productid=ROUND(RAND()*(SELECT MAX(productid) FROM product));
The result should be 0 or 1 results (0 due to data gaps, 1 if a record is found), however it results in multiple results a good number of times (very easy to reproduce, 90% of queries have more than 1 result).
Sample output:
+-----------+ | productid | +-----------+ | 11701 | | 20602 | | 22029 | | 24994 | +-----------+
(Number of records in DB is about 30k).
Running a single SELECT RAND()
always results in a single result.
Who can explain this behavior?
Aucun commentaire:
Enregistrer un commentaire