Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Query random rows in mysql DB with prisma. - Theo's Typesafe Cult
TTC
Theo's Typesafe Cult
•
4y ago
Christian Lind
Query random rows in mysql DB with prisma.
I
'm trying to query random rows in a mysql db with prisma
.
My first solution was to run a raw query
, like this
.
const randomOrd = await ctx.prisma
.$queryRaw
const randomOrd = await ctx.prisma
.$queryRaw
SELECT
* FROM Ord ORDER BY RAND
(
) LIMIT
$
{number
}
;
;
;
But I also want to select related tables
, and using the normal prisma methods i have done that by using the INCLUDE parameter
.
Is there a smart way to get random rows using prisma
, and not raw queries
?
Theo's Typesafe Cult
Join
26,564
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Case sensitive search in MySQL with Prisma
TTC
Theo's Typesafe Cult / questions
4y ago
Shadow db with prisma
TTC
Theo's Typesafe Cult / questions
4y ago
prisma query
TTC
Theo's Typesafe Cult / questions
4y ago
Handle many-to-many relations in Prisma with MySQL
TTC
Theo's Typesafe Cult / questions
3y ago