Using QMF


Selecting columns and tables

The format of SQL queries requires you to select columns before you select tables.

To select columns: 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 the columns to view on the report, type:

SELECT *

To find column names: If you know the table from which you want to select data, but don't know all the column names, you can use the Draw function key on the SQL Query panel.

  1. 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.

  2. Press the Draw function key.

    QMF displays a query that selects all the columns for the table you specified:

    SELECT DEPTNUMB, DEPTNAME, MANAGER, DIVISION  -- Q.ORG
         , LOCATION                               -- Q.ORG
    FROM Q.ORG
    
  3. Leave the query as is, or change it to select specific rows.

To select tables: Type FROM, followed by the name of the table from which you want to select data.

For example, to select the Q.ORG table, type:

FROM Q.ORG

If you need to see a list of tables, use the LIST TABLES command. For more information on the LIST TABLES command, see Displaying a list of database objects using the LIST command.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]