# Selects

## Specifying A Select Clause

Of course, you may not always want to select all columns from a database table. Using the `from` method, you can specify a custom `from` clause for the query:

```javascript
var getResults = query.from('users')
    .get('name,email,age');
writeDump(getResults);
```

Individual columns can contain fully-qualified names (i.e. "some\_table.some\_column"), fully-qualified names with table aliases (i.e. "alias.some\_column"), and even set column aliases themselves (i.e. "some\_column AS c"). Columns can be a single column, a list or columns (comma-separated), or an array of columns.

```javascript
var getResults = query.from('users')
    .get('name as myAccountName,users.email,age');
writeDump(getResults);
```

```javascript
var getResults = query.from('users as myTableAlias')
    .get( columns = ['name as myAccountName' ,'myTableAlias.email' ,'age'], options= { datasource='myOtherDatasource'} );
writeDump(getResults);
```

The `distinct` method allows you to force the query to return distinct results:

```javascript
var getResults = query.from('users')
    .select('email')
    .distinct();
writeDump(getResults);
```

(Note that `distinct` applies to the entire query, not just certain fields.)

If you already have a query builder instance and you wish to add a column to its existing select clause, you may use the `addSelect` method:

```javascript
var getResults = query.from('users')
    .where('age','>=','18');
getResults = getResults.addSelect('name,email,age').get();
writeDump(getResults);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qb.ortusbooks.com/6.4.0/query-builder/selects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
