I have found a solution to my problem, by using prisma.$queryRaw which I actually didn't know it existed for the few months I've been using it and only stumbled upon it now. Here's the documentation link for reference: Prisma - Raw database access

The end solution was:

await prisma.$queryRaw`SELECT * FROM FIRST JOIN SECOND ON FIRST.LPR=SECOND.LPR`

P.S. The only issue I ran into by using the queryRaw method instead of the regular Prisma Client was that the BLOB type values are retrieved as strings, instead of as a Buffer, but that can be handled both on the front-end as well as in the back-end accordingly with minor modifications to the response.

Answer from V. S. on Stack Overflow
🌐
GitHub
github.com › prisma › prisma › discussions › 20563
How to Join and Union in rawQuery · prisma/prisma · Discussion #20563
August 8, 2023 - prisma.$queryRaw` SELECT 'Expense' AS type, e.id AS record_id, e.title, e.amount, e.updatedAt AS record_updatedAt, GROUP_CONCAT(ec.name, ', ') AS category_names FROM Expense e JOIN CategoriesOnExpense coe ON e.id = coe.expenseId JOIN ExpenseCategory ec ON coe.categoryId = ec.id WHERE e.ownerId = ${userId} AND e.year = ${year} AND e.month = ${month} UNION SELECT 'Income' AS type, i.id AS record_id, i.title, i.amount, i.updatedAt AS record_updatedAt, GROUP_CONCAT(ic.name, ', ') AS category_names FROM …
Author   prisma
🌐
Prisma
prisma.io › home › raw queries › raw queries › raw queries › raw queries
Raw queries | Prisma Documentation
Prisma Client specifically uses SQL Template Tag, which exposes a number of helpers. For example, the following query uses join() to pass in a list of IDs:
Discussions

Queryraw condition joining
Question I need to use a procedure and then filter on this from a sqlserver database. I am having some issues constructing a query that is dynamic and safe. Prisma.join is only for joining values, ... More on github.com
🌐 github.com
2
2
July 23, 2024
mysql - Is it possible to make a join query with Prisma without a foreign key? - Stack Overflow
Did you read the manual specifically ... keys to join tables.. ... I forgot to specify that I wanted to use the PrismaClient to do so. V. S. – V. S. 2022-05-13 12:05:07 +00:00 Commented May 13, 2022 at 12:05 ... Save this answer. ... Show activity on this post. I have found a solution to my problem, by using prisma.$queryRaw which I actually didn't know it existed for the few months I've been using it and only stumbled upon it now. Here's the documentation link for reference: Prisma - Raw database ... More on stackoverflow.com
🌐 stackoverflow.com
using `queryRaw` with `sql` to do javascript functions?
Thank you for your understanding and ongoing support of the Prisma community! Beta Was this translation helpful? Give feedback. ... Sign up for free to join this conversation on GitHub. Already have an account? More on github.com
🌐 github.com
2
1
postgresql - Prisma $queryRaw with variable length parameter list - Stack Overflow
But when you use uuid type, Prisma's join function formats the parameters adding double apostrophe. So you can take error like 'type mismatch' in PostreSQL. Alternatively, you can use native Array.join function to build a sql string and send it to Prisma raw query function using Prisma.raw function. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › prisma › prisma › discussions › 17158
Joined Relations with $queryRaw · prisma/prisma · Discussion #17158
The $queryRaw method will return the data as it is retrieved from the database, which means that if you perform a join in your raw SQL query, the result will be a flat structure with columns from both tables.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › discussions › 24838
Queryraw condition joining · prisma/prisma · Discussion #24838
July 23, 2024 - The conditions array is joined with AND using Prisma.join with a string separator ' AND '. The final query is constructed using Prisma.sql, ensuring that the SQL string and the parameters are correctly aligned.
Author   prisma
🌐
Prisma
prisma.io › home › relation queries › relation queries › relation queries › relation queries
Relation queries (Concepts) | Prisma Documentation
join (default): Uses a database-level LATERAL JOIN (PostgreSQL) or correlated subqueries (MySQL) and fetches all data with a single query to the database.
Find elsewhere
🌐
Prisma
prisma.io › blog › prisma-orm-now-lets-you-choose-the-best-join-strategy-preview
Choosing the Best Join Strategy in Prisma ORM: join vs query
February 21, 2024 - Prisma ORM supports two strategies for loading related data. With the join strategy, the database merges the relations itself and returns nested data from a single SQL query, using JSON aggregation and lateral joins on PostgreSQL.
🌐
Prisma
prisma.io › docs › reference › tools-and-interfaces › prisma-client › raw-database-access
Raw database access (Reference) | Prisma Documentation
Prisma Client specifically uses SQL Template Tag, which exposes a number of helpers. For example, the following query uses join() to pass in a list of IDs:
🌐
DEV Community
dev.to › aws-builders › i-ditched-prisma-for-raw-sql-and-my-queries-got-10x-faster-4gen
I Ditched Prisma for Raw SQL (And My Queries Got 10x Faster) - DEV Community
April 6, 2026 - Prisma executes this as 4 separate queries: one for projects, one for members, one for apiKeys, one for the count. Then it assembles the result in JavaScript. The raw equivalent is one query.
🌐
GitHub
github.com › prisma › prisma › issues › 13517
SQL joins without relations/foreign keys/raw query · Issue #13517 · prisma/prisma
May 27, 2022 - Problem I sometimes find myself wanting to join 2 tables that are related by a column, but don't have referential integrity. For example, let's say I have 2 tables, Transaction and SmartContract (think Ethereum). Every Transaction belong...
Author   prisma
🌐
DEV Community
dev.to › this-is-learning › its-prisma-time-execute-your-own-queries-4olp
It's Prisma Time - Execute your own queries - DEV Community
January 28, 2022 - Let's move on and see another feature that we can adopt when we are using these methods. Sometimes we have to use the IN operator in a custom query. Probably you are thinking that using the map method of the array is the right thing, unfortunately it's not so. To do this, Prisma exposes us a specific method Prisma.join.
🌐
MCP Servers
mcpservers.org › home › agent skills library › prisma-client-api-raw-queries
prisma-client-api-raw-queries | Agent Skills Library
import { Prisma } from '../generated/client' const column = 'email' const users = await prisma.$queryRaw` SELECT ${Prisma.raw(column)} FROM "User" ` ... import { Prisma } from '../generated/client' const email = '[email protected]' const query = Prisma.sql`SELECT * FROM "User" WHERE email = ${email}` const users = await prisma.$queryRaw(query) import { Prisma } from '../generated/client' const conditions = [ Prisma.sql`role = ${'ADMIN'}`, Prisma.sql`verified = ${true}` ] const users = await prisma.$queryRaw` SELECT * FROM "User" WHERE ${Prisma.join(conditions, ' AND ')} `
🌐
Atomic Spin
spin.atomicobject.com › prisma-queryraw
Building an SQL Query from Variables with prisma.$queryRaw
July 19, 2024 - Using prisma.$queryRaw, I was able to write a basic query that returned the data I needed. However, I also needed the query to filter and order the data.
🌐
YouTube
youtube.com › evoqys
Executing raw queries in Prisma - YouTube
Subscribe for more awesome content.Our Github Link: https://github.com/evoqysOur Instagram Handle: https://www.instagram.com/evoqys/Disclaimer: All the video...
Published   October 24, 2023
Views   1K
🌐
Jquagliatini
blog.jquagliatini.fr › en › posts › 2023-03-27-prisma-raw-queries-validation
How to validate your prisma raw query results - Pragmatist in training
March 27, 2023 - await prisma.$queryRaw` SELECT ( COALESCE(SUM(due_amount), 0) - COALESCE(SUM(paid_amount), 0) ) AS "dueAmount" FROM ( SELECT invoice.amount AS due_amount, SUM(payments.amount) AS paid_amount FROM invoice LEFT JOIN payments ON payments."invoiceId" = invoice.id ) _ `
🌐
Stack Overflow
stackoverflow.com › questions › 62272841 › graphql-prisma-with-nodejs-query-question
node.js - Graphql Prisma with nodejs query question - Stack Overflow
June 9, 2020 - Your LEFT JOIN is not needed · LIKE CONCAT -> StringFilter for prisma has contains, startsWith and endsWith · ORDER BY rand() is not supported by prisma, you have some options: shuffle the array in code or use prisma.raw for your query. Documentation: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/filtering https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access ·