How to do operations on multiple columns
Hi, let's say I have the following table structure:
A | B | C which are all ints
I would like to be able to find all rows such that a*a + b - 30 = c
I assume I would start like this:
Obviously the syntax for this does not work, so I am wondering if I am going about this the right way and also if this is even possible in prisma or if I have to do a rawsql query.
1 Reply
Prisma supports atomic number expressions:
https://www.prisma.io/docs/orm/reference/prisma-client-reference#atomic-number-operations
But they are designed for updating fields based on their current values in a way that prevents race conditions. They do not support complex expressions or conditions directly within a query filter.
You would need to use a Raw Query. You can also consider using TypedSQL:
https://www.prisma.io/docs/orm/prisma-client/using-raw-sql#writing-type-safe-queries-with-prisma-client-and-typedsql
Prisma Client API | Prisma Documentation
API reference documentation for Prisma Client.
Write Your Own SQL in Prisma Client | Prisma Documentation
Learn how to use raw SQL queries in Prisma Client.