> 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/single-table.md).

# Single table

Fetching data from your database via the query builder has a lot of similarities to writing plain SQL.

## Basic query

To get data from a single table in the most simple way you can just call for the specified columns from a table using the `selectFrom` function chain, followed by the `.query()` to execute the network call.

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

## Schema

For more complex database structures you may need to specify the `schema` of the table you're trying to reference if it's not in the public schema.

*NOTE: If the table is in the public schema, or the database does not support schemas then the `schema` field is **not** required.*

{% code fullWidth="false" %}

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

{% endcode %}

## Specifying columns

To request specific columns, just specify them in an array for each particular table you're accessing.

```typescript
const { data, error } = await db
    .selectFrom([
        {
            schema: 'custom_schema',
            table: 'table_name',
            columns: ['id', 'first_name', 'last_name'],
        }
    ])
    .query()
```

### Requesting all columns

Similar to SQL, if you want to request all columns from a table you can use the `*` character to indicate all columns.

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