Skip to content

How do I order by RAND? #1009

Answered by billy1624
alper asked this question in Q&A
Aug 31, 2022 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

Hey @alper, hi there! This is more of a SQL related question. But yeah, you can order the result in random order with ORDER RAND() / ORDER RANDOM() depending on which db you're on.

We don't have RANDOM function in SeaQuery yet. So, you'd have to go with Expr::cust().

However, a small PR would be appreciated to introduce the support of RANDOM function. Add a RANDOM variant to https://github.com/SeaQL/sea-query/blob/cb6fd12ecec848cfe90f05ad7f2a27f2db25028c/src/func.rs#L8-L27

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@alper
Comment options

Answer selected by billy1624
Comment options

You must be logged in to vote
5 replies
@billy1624
Comment options

@rbozan
Comment options

@YiNNx
Comment options

@logistic-bot
Comment options

@logistic-bot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants