Printing Columns

You can select any column from one of the tables listed in the FROM clause, you can also use expressions to display columns derived any of these columns. The specified tables are joined and the expressions are extracted from the join and the columns printed, for example:

SELECT NAME FROM CUSTOMER;

prints all the names of all the entries in the CUSTOMER table.

AS

You can use the word AS to name or rename a column, for example:

SELECT NAME AS CUST_NAME FROM CUSTOMER;

Column aliases are only useful when accessing the database via ODBC - for example they allow a program accessing the database via ADO to access a derived column by name rather than ordinal. The new name is for "external" use only - it cannot be used elsewhere in the statement.

DISTINCT

The word DISTINCT can be used to eliminate duplicate lines, for example:

SELECT DISTINCT NAME FROM CUSTOMER;

prints each name once, even if there are several customers of that name.

Column Abbreviations

In the list of expressions to be printed, the shorthand forms: <table>.*, meaning 'all the fields in <table>' , and *, meaning 'all the fields in all the tables of the FROM clause', are available. For example:

SELECT * FROM CUSTOMER;

prints the whole CUSTOMER table.

When you use column abbreviations, especially an unqualified * in a multi-table query, the order of the fields may not be what you expect. The DP4 SQL Engine will not necessarily order the columns in the order of the tables. Use a list of <table>.* abbreviations instead if the column order matters.