Hi i’m trying to get some random results ordered by the location ASC.
This is my query:
SELECT `location`, `route`
FROM (`foo`)
WHERE `location` != ''
ORDER BY RAND(), `location` ASC
LIMIT 8
the problem is that it gets randomly but doesn’t orders then by “location” ASC, also if i do this:
SELECT `location`, `route`
FROM (`foo`)
WHERE `location` != ''
ORDER BY `location` ASC,RAND()
LIMIT 8
it doesn’t gets randomly.
How can i get both togheter RAND() and ORDER BY location ASC ?
You need nested statements/queries: