The select statement returns an array of records (nid). It can be combined with the where, from, and to clauses.
Example:
The following example retrieves the first 10 first names from the Customer table where the first name contains the letter "s":
(select Customer where 'First name' like "s" from 0 to 9).'first name'
Clause where
The content of a where clause is executed on the server.
Therefore, it is not possible to use certain functions, such as alert or dialog, within a where clause.
From and To
Using from and to, only records from index 0 to 9 will be returned.
This feature is useful for retrieving the first x records or for paginating query results.
Execution Block
The execution block is the part after the period at the end of the select statement. In the example above, the execution block is 'first name'.
A more complex execution block can include variables or even additional select statements. Like functions, the last statement in the block determines the type and value of the resulting array.
Example:
The following code produces an array of numbers, representing the total sales for each customer:
(select Customer where 'First name' like "s" from 0 to 9).
(
vara:= id;
vari:= select invoice where customer = a;
sum(i.TOTAL);
)
Warning:
For execution blocks that include access to other tables, there may be bugs if the code is executed on the server.
In such cases, it is better to use a for i in select loop instead.