Is there a way to include template string inside r...
# orm-help
h
Is there a way to include template string inside raw query
Copy code
prisma.$queryRaw` 

// template string used in the raw sql query
 `
1
n
Hey Hussam 👋 You can pass template literal in queryRaw which would allow you to insert variables. Here’s an example:
Copy code
const email = '<mailto:emelie@prisma.io|emelie@prisma.io>'
const result = await prisma.$queryRaw`SELECT * FROM User WHERE email = ${email}`
h
Yes I did see this in the docs. My goal is not to pass dynamic variables(eg shown as harcoded here). I like to use template strings inside template strings (i.e inside sql.$rawquery``) Eg placing of ``count(total users)`` Inside of sqlrawquery
n
I am not exactly able to understand. Can you please share the exact queryRaw string that you are trying to execute?
h
Sure , check out the last query in the link. This is the rawquery I wanted to execute in prisma https://dbfiddle.uk/?rdbms=mysql_8.0&amp;fiddle=201d21d3eb37758b9a5f4f7c0c34823b
n
Oh I see what you mean by using template strings inside template strings, I think you should be able to use it, you would just need to escape them through backslash (\)
I haven’t tried executing this query though
Let me know if you get any error if you try to execute it?
h
Perfect !! Sorry, this was not related to Prisma at all.