Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to order by random() in ORMLite

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

I tried but get error:

myQueryBuilder.orderBy("random()", true);
like image 272
weldsonandrade Avatar asked Jul 12 '13 13:07

weldsonandrade


1 Answers

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

myQueryBuilder.orderByRaw("RANDOM()");
like image 86
weldsonandrade Avatar answered Oct 20 '22 20:10

weldsonandrade