limiting a join when filtering by an extra field.
I have a query which finds properties based on how far away they are from a certain point and then joins some other tables.
I would also like to join a
propertyImages
table but I only want to bring the first 5 of them. I know that this is beautifully easy using relational queries because I can do
However, I am not sure if this filtering based on a calculated field is possible. extras
is there but then I can't include that in the where clause of the relational query. Maybe I should not join the images table and do a subquery there?1 Reply
basically, turning this from the drizzle docs into a relational query:
https://orm.drizzle.team/docs/select#select-from-subquery
Select from subquery
Just like in SQL, you can embed queries into other queries by using the subquery API:
Subqueries can be used in any place where a table can be used, for example in joins: