Skip to content

Commit

Permalink
Update Let example in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexFrid authored Jan 7, 2025
1 parent c6d0c69 commit 4fda5a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/content/doc-surrealql/statements/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@ More info on the `$parent` parameter in the second example can be seen on [the p

```surql
-- Store the subquery result in a variable and query that result.
LET $history = SELECT * FROM events WHERE type = 'activity' LIMIT 5;
SELECT * from $history;
LET $avg_price = (
SELECT math::mean(price) AS avg_price FROM product GROUP ALL
).avg_price;
-- Find the name of the product where the price is higher than the avg price
SELECT name from product
WHERE [price] > $avg_price;
-- Use the parent instance's field in a subquery (predefined variable)
SELECT *, (SELECT * FROM events WHERE host == $parent.id) AS hosted_events FROM user;
Expand Down

0 comments on commit 4fda5a7

Please sign in to comment.