Use the QUERY command to select, combine, manipulate, and retrieve data from tables.
Options
*
Specifies all columns.
,
Indicates that this part of the command is repeatable.
colname
Specifies a column name. The column name is limited to 128 characters.
In a command, you can enter #c, where #c is the column number shown when the columns are listed with the LIST TABLES command. In an SQL command, a column name can be preceded by a table or correlation name and a period (tblname.colname). You can enter tblname.* to specify all columns in the table.
corr_name
Correlation name. A nickname or alias for a table or view name. Use corr_name to refer to the same table twice within the command, or to more briefly specify a column in more than one table.
EXECUTE
Retrieves columns and their data, then displays the columns with their data in the Data Browser.
(expression)
Determines a value using a text or arithmetic formula. The expression can include other columns from the table, constant values, functions, or system variables such as #date, #time, and #pi.
FROM tblview
Specifies the name of the table(s) or view(s) to query.
ORDER BY clause
Sorts rows of data. For more information, see ORDER BY.
tblname.
Specifies the table containing the columns. You can use tblname.*to specify all columns in the table.
WHERE clause
Limits rows of data. For more information, see WHERE.
About the QUERY Command
You construct a query to get information from your database's tables and columns. The process of selecting, retrieving, and working with data is referred to as creating and executing a query. R:BASE processes the query and displays what you request.
You can specify a maximum of ten tables and correlation names.
You can save the query as a view, or you can create a new table from the columns.
In R:BASE for Windows QUERY starts the Query By Example option from the Tools menu. After you enter the command QUERY, what R:BASE displays depends on the options you specified.
To display... |
Do the following... |
The "Query By Example" window |
Use the QUERY command without specifying any options. |
The "Query By Example" window and the query contained in the QUERY command |
Use the QUERY command with any option except EXECUTE. |
The Data Browser with the data retrieved by the QUERY command |
Use the QUERY command with EXECUTE and any other option. |
Examples
The following command chooses all the columns from the customertable and displays the columns' names and data on the screen.
QUERY * FROM customer EXECUTE
The next command selects the empid, empfname, and emplname columns from the employee table, and displays the column names on the screen.
QUERY empid, empfname, emplname FROM employee
The following command selects the data from the custid column in the customer table and the matching netamount columns in the transmaster table. T1 and t2 are correlation names. In the WHERE clause, the link is established between the two tables by comparing the values of the custid column between the two tables. The linking columns can have different names; however, they must have the same data type.
QUERY t1.custid, t2.netamount FROM customer t1, transmaster t2 +
WHERE t1.custid = t2.custid EXECUTE