Database |> Language |> Keywords |> 

WHERE

Contents

Definition

When you are interested in filtering the collection of data before you at a particular point in an LSD trip, the WHERE keyword is how you can specify the way in which you are interested in filtering records.

FROM starting_point
|> GROUP BY container
|> SELECT field
|> WHERE field != ''

The WHERE expression is evaluated on the data leading up to that line and not pre-emptively meaning the below statement would not exclude records where field is an empty string.

FROM starting_point
|> WHERE field != '' -- Does not filter since defined before data was defined
|> GROUP BY container
|> SELECT field

Example

There’s an open source grant program run by Daniel Gross and Nat Friedman called AI Grant and it’d be nice to be able to quickly answer the question of “what is backed by them currently?”. If we were to just grab all the links on the page like so:

Run the below query yourself

aigrant <| https://aigrant.org |
recipient <| a@href |
link <| a |

FROM aigrant
|> GROUP BY link
|> SELECT recipient

Then we would end up including their accelerator as well as their compute credits so let’s include a WHERE expression to distill down the results to just the data we’re interested in.

Run the below query yourself

aigrant <| https://aigrant.org |
recipient <| a@href |
link <| a |

FROM aigrant
|> GROUP BY link
|> SELECT recipient
|> WHERE recipient != "https://aigrant.com" AND recipient != "https://andromeda.ai"

Related: