Prisma query multiple tables
So, I have 3 tables that need to be queried. Their schema are very much alike, underlined fields are basically shared between them.
I need to 'join' them, I guess, and do a pagination based on timestamp.
How would I go about doing this?
![](https://cdn.answeroverflow.com/1118542076926238750/Screenshot_2023-06-14_at_17.03.24.png)
5 Replies
something like this
you want to read this https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries
Prisma
Relation queries (Concepts)
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
yeah, it's almost what I was looking for. Unfortunately, I wasn't able to come up with a query that would let me implement pagination, so I wound up using prisma.$queryRaw and writing some SQL.
Thanks anyway.
Can you provide some more details? I'm pretty sure what you're asking for can be done
Okay, so: I have 3 tables with exact same schemas as per screenshot: Withdraw, Topup, Profit. I need to query them all 3 together, where userId matches with userId from current session and get rows ordered by 'createdAt'.
Like this: