> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/wirebootstrap/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/wirebootstrap/reference/wire.data/wire.data.tablequery.md).

# wire.data.TableQuery

The `TableQuery` class is used to create queries.  Use the `wire.data.select` method to create `TableQuery` instances.

The following makes a call to a custom web service method `GetUsers` and returns the results into the `data` variable.

```javascript
const accountService = new wire.data.DataSource("custom", {
    ...
});

const query = wire.data.select().from("GetUsers")

const data = accountService.exec(query);
```

`TableQuery` has many methods which allow a target data source to be queried.  Check the target [service provider](/wirebootstrap/connecting-to-data/data-connectors.md) documentation for details including support for `TableQuery`.

The full list of `wire.data.select` methods available is listed below.

```javascript
 wire.data.select([fields])
 
  [.top(number)]
  [.distinct()]
  [.field(field)]
    [.eventName(name)]
 
  .from([entity])
 
  [.join(entity)]
  [.leftJoin](entity)]
  [.rightJoin](entity)]
  [.on(entity,field)]
  [.onValue(field, value)]
 
  [.where([custom expression])]
    [.expression(expression)]
    [.eq(field,value)]
    [.ne(field,value)]
    [.in(field,[values])]
    [.between(field,value1,value2)]
    [.starts(field,value)]
    [.contains(field,value)];
    
  [.groupBy(fields)]
  [.orderBy(field, [desc])]
```

The following example selects the list of active users directly from a SQL database using the [WireBootstrap Query Service](https://docs.wirebootstrap.com/query-service).

```javascript
const accountService = new wire.data.DataSource("table", {
    ...
});

const query = wire.data.select("UserName")
    .from("Users")
    .where().eq("Active", true);
    
const table = accountService.exec(query);
```

For more `TableQuery` examples, visit [Creating Queries - Select Queries](/wirebootstrap/creating-queries/select-queries.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.tablequery.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.
