> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xano.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Assistant

> Learn how to use the SQL Assistant to help build complex SQL queries for your database

The SQL Assistant can help you build complex SQL queries for your database. It's useful when utilizing the [Direct Database Query](/the-function-stack/functions/database-requests/direct-database-query) function, or when you need to build a query that isn't supported by the visual [Query All Records](/the-function-stack/functions/database-requests/query-all-records) function.

### Using the SQL Assistant

<Steps>
  <Step title="Find the SQL Assistant">
    <Frame caption="You'll find the SQL Assistant in the top-right corner of the Direct Database Query function.">
      <img src="https://mintcdn.com/xano-997cb9ee/4xy0p5vdU3hAE_8U/images/sql-assistant-20251011-083958.png?fit=max&auto=format&n=4xy0p5vdU3hAE_8U&q=85&s=2ad49c1fcbbb0bdd15d917ef8557e452" alt="sql-assistant-20251011-083958" width="615" height="330" data-path="images/sql-assistant-20251011-083958.png" />
    </Frame>
  </Step>

  <Step title="Tell the Assistant about the query you're trying to build">
    The Assistant has access to your database (as long as you've accepted the A.I. Assistant terms and conditions), so it can understand queries like "get me all the records from the users table where the age is greater than 30" or "get me all the records from the users table who have placed orders in the last 30 days".

    You can also ask the Assistant to build a query from scratch, or to modify an existing query.
  </Step>

  <Step title="Review and Iterate">
    Once the Assistant has taken a first pass at your question, you can continue to converse with it to iterate and expand, or correct missteps.
  </Step>
</Steps>
