> For the complete documentation index, see [llms.txt](https://outerbase.gitbook.io/untitled/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://outerbase.gitbook.io/untitled/query-builder/select.md).

# Select

Fetching data from your SQL database happens with a `SELECT` statement.

Typically in SQL the syntax would look like the below statement which would return all of the rows from the table, `table_name` and for each row only return the columns named `column_1` and `column_2` – but nothing else.

```sql
SELECT column_1, column_2 FROM table_name
```

When using the Outerbase query builder you can accomplish the same SQL statement with the following code.

<pre class="language-typescript"><code class="lang-typescript"><strong>const { data, error } = db
</strong><strong>    .selectFrom([
</strong><strong>        { table: 'table_name', columns: ['column_1', 'column_2'] }
</strong><strong>    ])
</strong><strong>    .query()
</strong></code></pre>

## Specifying a schema

For some databases, tables are nested within a schema which you can in some ways think of as a folder to help categorize your tables intent. By default many database engines have a root schema named `public` but you do not need to specify `public` in your SQL statements as it is implied.

However, if you have custom schemas then it is important to specify a schema before the table. In SQL it might look like the statement below.

```sql
SELECT * FROM my_schema.table_name
```

Because the table lives as a child of `my_schema` we must specify the parent child relationship in the query so the database engine knows where to find that table specifically.

To accomplish this in the query builder you can do so by specifying the schema in addition to the table name and columns.

```typescript
const { data, error } = db
    .selectFrom([
        { 
            schema: 'my_schema',
            table: 'table_name',
            columns: ['*']
    ])
    .query()
```
