Selecting columns and tables
The format of SQL queries requires you to select columns before you select tables.
Procedure
To select columns, choose one of the following options:
- Type SELECT, followed by the names
of the columns in the order that you want them to appear on the report.
Use commas to separate the column names.
For example, to select the DEPTNAME and DEPTNUMB columns, type SELECT DEPTNAME, DEPTNUMB
To select all columns in the table, type SELECT *
- If you know the table from which you want to select data,
but do not know all the column names, you can use the Draw function
key on the SQL Query panel to display the column
names.
- On the QMF command
line, type the name of the table whose columns you want to see.
For example, to find the names of the columns in the Q.ORG table, type Q.ORG. If you need to see a list of tables, use the LIST TABLES command.
- Press the Draw function key.
QMF displays a query that selects all the columns for the table you specified:
SELECT DEPTNUMB, DEPTNAME, MANAGER, DIVISION , LOCATION FROM Q.ORG
- Leave the query as is, or change it to select a subset
of data. For example, you can delete certain columns or specify criteria for selecting specific rows).
- On the QMF command
line, type the name of the table whose columns you want to see.