-2

Is there any way I could re-write this SQL query using Prisma Client.

SELECT TOP 1 * FROM [myTable] 
WHERE Name = 'Test' and Size = 2 and PType = 'p'
ORDER BY ABS( Area - @input ) 
user3278869
  • 3
  • 1
  • 5

1 Answers1

0

You can use queryRaw and directly pass the raw SQL to execute it.

It would look like this:

const result = await prisma.$queryRaw`SELECT TOP 1 * FROM [myTable] 
WHERE Name = 'Test' and Size = 2 and PType = 'p'
ORDER BY ABS( Area - @input )`
Nurul Sundarani
  • 5,550
  • 3
  • 23
  • 52