Very Simple Subquery Returning Strange Results
All I want is a single random value from this MySQL query. Both the outer inner and outer queries reference the same table but I'm assigning them different aliases. Yet, this query is still performing like a correlated subquery, often returning multiple results.
The inner query performs as expected if extracted and ran by itself, returning only a single random value.
select img.* from images img where img.image_id = (select floor(max(i.image_id) * rand()) + 1 from images i)