> ## Documentation Index
> Fetch the complete documentation index at: https://lightdash-mintlify-9d6f9427.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL variables

> When writing SQL in your Lightdash models, you can use the following references to template your SQL and make it more reusable

* `${field}` - reference a field in the current model
* `${model.field}` - reference a field in another model
* `${TABLE}` - reference the current table's sql reference
* `${lightdash.attributes.my_attr_1}` - a user attribute called `my_attr_1`
  * (optional) `ld` as an alias for `lightdash`
  * (optional) `attribute` or `attr` as an alias for `attributes`
* `${lightdash.user.<intrinsic_attribute>}` - reference an `intrinsic_attribute` of the current Lightdash user
  * (optional) `ld` as an alias for `lightdash`
  * available intrinsic user attributes:
    * `email`

<Info>
  **The user email attribute is only available when the email is verified.**

  This is a security measure to prevent users from creating/updating an account with any email they don't own and gain access to data they shouldn't see.

  If the user email is not verified you will get the following error:

  <Frame>
    <img src="https://mintcdn.com/lightdash-mintlify-9d6f9427/u4PJkm0BuJuKtNvT/images/references/workspace/user-attributes-info.png?fit=max&auto=format&n=u4PJkm0BuJuKtNvT&q=85&s=129af9223483cf0b181f4ca1595c9bc1" alt="" width="438" height="72" data-path="images/references/workspace/user-attributes-info.png" />
  </Frame>

  ```yaml theme={null}
  models:
    - name: example
      meta:
        sql_filter: ${lightdash.user.email} = 'example@lightdash.com'
  ```

  If you are self hosting you can enable [SMTP](/self-host/customize-deployment/configure-smtp-for-lightdash-email-notifications) or [SSO](/self-host/customize-deployment/use-sso-login-for-self-hosted-lightdash) authentication to allow users to verify their email address.
</Info>
