Where – HP Intelligent Management Center Standard Software Platform User Manual

Page 702

Advertising
background image

identify the table in your report. The following example illustrates the FROM
clause used with the SELECT clause:

SELECT

TABLEA.'CUSTNAME',
TABLEA.'STATE'

FROM

'TABLEA' TABLEA

WHERE

The WHERE clause has two purposes:

To specify record selection criteria.

To show how two database tables are joined.

When WHERE is used to specify record selection criteria, it includes a search
condition in order to determine which records (rows of data) are to be
retrieved. For example:

SELECT

MYTABLE.'SALESPERSON',
MYTABLE.'SALESTOTAL'

FROM

'MYTABLE' MYTABLE

WHERE

MYTABLE.'SALESTOTAL' < 10000.00

When WHERE is used to specify how two tables are linked, an SQL join
operator sits between the two table names. See

Linking options

.

The following is an example of the WHERE clause joining two tables:

SELECT

CUSTOMER.'CUST_ID',
CUSTOMER.'CUST_NAME',
ORDERS.'AMOUNT'

FROM

'CUSTOMER' CUSTOMER,
'ORDERS' ORDERS

WHERE

CUSTOMER.'CUST_ID' = ORDERS.'CUST_ID'

702

Crystal Reports 2008 SP3 User's Guide

Understanding Databases

25

Using SQL and SQL databases

Advertising