diff --git a/website/Space Lua/Lua Integrated Query.md b/website/Space Lua/Lua Integrated Query.md index f1ebe654..ea515e4a 100644 --- a/website/Space Lua/Lua Integrated Query.md +++ b/website/Space Lua/Lua Integrated Query.md @@ -6,34 +6,43 @@ Lua Integrated Query (LIQ) is a SilverBullet specific Lua extension. It adds a c The syntax for LIQ is `query[[my query]]`. In regular Lua `[[my query]]` is just another way of writing `"my query"` (it is an alternative string syntax). Function calls that only take a string argument can omit parentheses, therefore `query[[my query]]` is equivalent to `query("my query")`. -However, in [[Space Lua]] it is interpreted as an SQL (and [LINQ](https://learn.microsoft.com/en-us/dotnet/csharp/linq/))-inspired integrated query language. +However, in [[Space Lua]] it is interpreted as an SQL- and [LINQ](https://learn.microsoft.com/en-us/dotnet/csharp/linq/)-inspired integrated query language. General syntax: - query [[ - from - where - group by [, ...] - having - order by - [asc | desc | using ] - [nulls {first | last}] - [, ...] - limit [, ] - offset - select - ]] +```postgres +query [[ + from <> + [ where <> ] + [ group by <> [, ...] ] + [ having <> ] + [ order by <> [, ...] ] + [ limit <> [, <>] ] + [ offset <> ] + [ select <> ] +]] +``` -Aggregate functions support an optional intra-aggregate `order by` and/or `filter` clause: +Unlike in SQL where clauses must be written in a particular order, LIQ clauses can be written in any order, and the only mandatory clause is the `from` clause. - ( [, ...] - [order by - [asc | desc | using ] - [nulls {first | last}] - [, ...]] - [filter(where )]) +The `order by` clause uses `<>`: -These can be combined. See [[Space Lua/Lua Integrated Query/Aggregating]] for details. +```postgres +<> + [ asc | desc | using <> ] + [ nulls { first | last } ] +``` + +If an aggregate function call is used for projection (`select`), the general syntax is: + +```postgres +<>( <> [, ...] + [ order by <> [, ...] ] + [ filter (where <>) ] +) +``` + +See [[Space Lua/Lua Integrated Query/Aggregating]] for details. LIQ operates on any Lua collection.