K
Kysely2y ago
Nick

How to sort by random?

Imagine this query:
export default function findUsers() {
return db
.selectFrom('person')
.selectAll()
.where('age', '>', 5)
.orderBy('age', 'desc');
}
export default function findUsers() {
return db
.selectFrom('person')
.selectAll()
.where('age', '>', 5)
.orderBy('age', 'desc');
}
Instead of sorting by age, how would I sory by random?
Solution:
orderBy(sql`random()`)
orderBy(sql`random()`)
Should do it...
Jump to solution
1 Reply
Solution
koskimas
koskimas2y ago
orderBy(sql`random()`)
orderBy(sql`random()`)
Should do it
Want results from more Discord servers?
Add your server