How to order by random() in ORMLite
Asked Answered
O

1

7

How to make a query to get random() rows with limit of 3 rows?

I tried but get error:

myQueryBuilder.orderBy("random()", true);
Obsequent answered 12/7, 2013 at 13:28 Comment(0)
O
10

I solved it by using the orderByRaw(...) method:

myQueryBuilder.orderByRaw("RANDOM()");
Obsequent answered 12/7, 2013 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.