> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/orm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wirebootstrap.com/orm/tables-and-views/select.md). Agents can also search and read this documentation through its [MCP server](https://docs.wirebootstrap.com/orm/~gitbook/mcp).

# Select

To begin working with an entity, start with the name of the entity.  Use the `select` method to begin a new query.  This method returns a new instance of the entity class.  When finished, use the `execAsync` method to execute the query in the database and return the records as a [strongly typed version of the WireBootstrap DataTable](https://docs.wirebootstrap.com/orm/tables-and-views.md#datatable-interface).&#x20;

The example below will return all the records and fields in the `Categories` table in the `Northwind` database.

```javascript
const categoryTable = await Categories.select().execAsync();
```

Note, the `execAsync` method returns a TypeScript `Promise` so the `await` keyword can be used to execute the query asynchronously.

## Fields

To select fields from an entity, use the *\[entity]Field* `enum` parameters on the `select` method.

```javascript
const categoryTable = await Categories.select(
    CategoriesField.CategoryID, 
    CategoriesField.CategoryName
)
.execAsync();
```

The `field` method can also be used to select fields.

```javascript
const categoryTable = await Categories.select()
   .field(CategoriesField.CategoryID)
   .field(CategoriesField.CategoryName)
.execAsync();
```

## Filter

To filter the records returned, use the `eq` method.

```javascript
const categoryTable = await Categories.select()
   .eq(CategoriesField.CategoryName, "Dairy Products") 
.execAsync();
```

## First

To return the first record in a result set, the `execFirstAsync` method can be used instead of the `execAsync` method.

```javascript
const dairyProducts = await Categories.select()
   .eq(CategoriesField.CategoryName, "Dairy Products") 
.execAsyncFirst();
```

Note, unlike the `execAsync` method which returns a data table, this method returns a single `Categories` object.

## Scaler

When selecting a single cell in a query,  the `execScalerAsync` method can be used.

```javascript
const categoryId = await Categories.select(
     CategoriesFields.CategoryID
   )
   .eq(Categories_Field.CategoryName, "Dairy Products") 
.execAsyncScaler();
```

## Order By

To order the records in the result set, use the `orderBy` method.

```javascript
const categoryTable = await Categories.select()
.orderBy(CategoriesField.CategoryName)
.execAsync();
```
