How can this query be written in prisma? ````SELE...
# orm-help
d
How can this query be written in prisma?
Copy code
`SELECT COUNT(g.id) AS 'total_used', s.`product_name`, s.`current_period_start` AS 'current_period_start', s.`current_period_end` AS 'current_period_end'
FROM `subscription` s
    JOIN `user` u ON s.`customer_id` = u.`customer_id`
    LEFT JOIN `goat` g ON g.`user_id` = u.`id` AND
          g.`date_created` BETWEEN s.`current_period_start` AND s.`current_period_end`
    WHERE u.`id` = "00000-00000" AND s.`status` = 'ACTIVE'
r
I think you would need to stick with a raw query on this one as you are comparing columns of one table with another and that’s not supported by Prisma.
đŸ‘€ 1
I would suggest adding a comment to this request or create a new one referencing this to allow extending fields from other tables.