SELECT – Projection

This statement uses a subset of the fields in the database to build a recordset.

Syntax

SELECT [tablename.]fieldname [,[tablename.]fieldname ...] FROM tablename

Parameters

fieldname

Specifies the name of a field in the table to include in the recordset.

tablename

Specifies the name of the table from which to retrieve data.

Remarks

Use this statement to build result sets that contain only the fields you want. Field names can be repeated or omitted. There are performance benefits to excluding field names—especially if only a few columns are needed from a table with a large number of fields, or if one of the unnecessary fields contains a large amount of data, such as a long string or varbinary data.

Field references must be separated by commas.

Example

The following code example shows how to use the projection SELECT statement to display the number of system tables.

Dim rs
Set rs = CreateObject("adoce.recordset")
rs.open "select tablename from msystables where tablename like 'msys%'"
MsgBox rs.RecordCount,,"records"
Msgbox rs.Fields.Count,,"fields"
Msgbox rs.Fields(0).Name
rs.Close
Set rs = Nothing