# select command

The select command retrieves all items
from the specified file reference that meet the optional selection
criteria. The items are selected in the order of their appearance
in the file reference. The selected item may be saved for future use
or acted upon immediately.

When an output list displays in any of the various select sentences, the list is built from the
 contents of the specified attribute. If an item list is specified, items are selected in the
 order of the item-IDs in the item list. If no item list is specified, all items in the file are
 considered. In this case, they display in order by the group into which they hash; and within
 groups, in the order they were added to the file.

If output specifications are included, the values of the specified attributes, including empty
 values, are used to form the list. If omitted, the list is formed from the item-IDs.
 The list is a temporary list that is used by the next command as its implicit item
 list. The list can be permanently saved by using the save-list or
 sl command. The list can also be passed to an Output
 processor command or to a FlashBASIC program if the next TCL command executes
 that program.

The elements of the list can be used as item-IDs to reference data in any file, not just the file
 referenced in the select command. For example, if a select
 on one file is followed by a list on a different file, the list of item-IDs generated by the
 select are used as an item list in the list command.

*output.specification* specifies the attribute-defining item from which values
 are to be extracted for creation of the list. (See the example below.) This is
 somewhat similar to using qselect, with the additional provision
 for being able to specify collation order and selection criteria.

Note: The select command can use an index, if
the index is created on the attribute, to narrow its selection criteria
when using a relational and logical operator. If an index is available,
the selection processor will use it when a single selection criteria
is used or when the AND logical operator is used
with two criteria. Indexes will not be used when the OR logical operator is used in the selection criteria.

## Syntax

```
select file.reference {item.list} {selection.criteria} {output.specification}
{modifiers} {(options}
```
Note: If by is provided with a command
that does not naturally sort (such as the select command), the command is changed to its sorting counterpart (for
example, select becomes sselect, and so on).

## Options

Options alter the behavior of the select sentence. They are placed last and must be preceded by a left parenthesis; the right parenthesis is optional. Multiple options can be combined with no delimiter between them (for example, `(tq`).

Because select builds an item list rather than a formatted report, the report-formatting options have little effect; the options most useful with select are listed below.

| Option | Description |
| --- | --- |
| t{number} | Displays a periodic running total of the progress of the select (also sselect and count): the approximate number of items selected followed by the approximate number scanned. The period defaults to every 100 items selected and can be changed by appending a number after the t. A select that uses an index does not display a running total. |
| q | Bypasses utilization of indexes, forcing the selection processor to scan the file instead of reading an index. |
| b, j | Suppress the n items selected message at the end of the select (see ni-supp modifier). |
| n | Prevents output from pausing at the end of each terminal page (see nopage modifier). |
| p | Directs output to the system printer, via the spooler (see lptr modifier). |
Nearly every option has an equivalent [modifier](https://d3codex.com/access/modifiers/) that performs the same function with a different syntax.

[Full referenceAll AQL options →The complete table of options every select, sselect, sort, and list sentence accepts, with descriptions and modifier equivalents.](https://d3codex.com/access/options-access-query-language/)The session below, run on D3 10.3.4, shows the b option in action. The first select reports its count; the second, with `(b`, builds the same list silently. The `>` prompt indicates an active select list is pending for the next command.

```
:SELECT MD
[404] 1723 items selected out of 1723 items.
>SELECT MD (B
>COUNT MD
[407] 1723 items counted out of 1723 items.
```
The t option displays a periodic running total while a long select scans the file. Here `(t50` reports progress roughly every 50 items selected:

```
:SELECT MD (T50
Selected Processed Total Completed
 68 68 1723 3%
 142 142 1723 8%
 ...
 1648 1648 1723 95%
 1723 1723 1723 100%
[404] 1723 items selected out of 1723 items.
```

## Example(s)

This builds a list of the item-IDs
that match the given selection criteria.

```
select invoices with amount.due > "0"
```
This creates a nonsorted list of the contents of the `order.pointers` attribute.
 For items where the`order.pointers` attribute is empty, an empty
 value will be returned to the select list.

```
select customers with last.order.amount > "1000" order.pointers
```
This creates a sorted list of all invoices whose item-ID
begins with the letter d and with an invoice date on or after January
1, 2005.

```
sselect invoices = ’d]’ with invoice.date ge "1/1/05" by date
```

## See also

- [Options (Access Query Language)](https://d3codex.com/access/options-access-query-language/)
- [Modifiers](https://d3codex.com/access/modifiers/)
- [sselect command](https://d3codex.com/access/sselect-command/)
- [nselect command](https://d3codex.com/access/nselect-command/)
- [require-select command](https://d3codex.com/access/require-select-command/)
- [sort command](https://d3codex.com/access/sort-command/)
- [count command](https://d3codex.com/access/count-command/)
- [selection criteria](https://d3codex.com/access/selection-criteria/)

---
Source: https://d3codex.com/access/select-command/ - part of the D3Codex reference.
