SELECT – Restricted

This statement restricts the data returned by comparing the data in the table against the conditions specified in the WHERE clause.

Syntax

SELECT * FROM tablename WHERE fieldname-expression [AND|OR fieldname-expression]

Parameters

tablename
Specifies the name of the table from which to retrieve data.
fieldname-expression
Can take one of the following forms:
fieldname
Specifies the name of a field in the table to use in a comparison operation.
operator
Can be one of the values described in the following table.
Operator
Description
= Equals
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal
<> Not equal

constant
Specifies a numeric string or date, enclosed by quotation marks.
string%
String constant followed by the “%” or “*” wildcard character. A wildcard character can also be used by itself to match everything. Use a wildcard character only at the end of the string constant.

Remarks

Parentheses can be used in the usual way to group expressions and establish precedence. The following additional rules apply to the WHERE statement:

Return Values

One of the following error values can be returned:

Example

Dim rs
Set rs = CreateObject("adoce.recordset")
rs.open "select * from msystables where tablename like 'msys%'"
MsgBox rs.RecordCount
rs.Close
Set rs = Nothing