I'm trying to fetch data in SQL first by RAND and then order those random fetched items by something else, like price.
None of the ways I've tried worked.
ORDER BY RAND(`parts`.price) DESC LIMIT 6
This, for example, fetches the same items over and over again.
ORDER BY RAND(),`parts`.price DESC LIMIT 6
This fetches random items, but does not sort them.
ORDER BY `parts`.price, RAND() DESC LIMIT 6
This fetches same items, not by random and not by price.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire