Defining the columns of a recordset
You can use SQL to define recordsets for your pages. A recordset is a subset of records extracted
from a database. For more information, see
Here's the basic SQL syntax to define the columns of a recordset:
SELECT ColumnName1, ColumnName2, ColumnNameX FROM TableName
If you want to include all the columns of a table in the recordset, you can use the wildcard
character *, as follows:
SELECT * FROM TableName
For example, suppose you have a table called
type the following
SELECT * FROM Customers
Suppose you only need the data contained in two columns of the
column and the
these two columns, you would type the following
SELECT YearBorn, DateLastPurchase
FROM Customers
Limiting the records in a recordset
Use a
clause to limit the number of records in the recordset. For example, you may want to
WHERE
include only those customers who earn more than $50,000 a year. Assume you have a column in
your table called
would read as follows:
SELECT YearBorn, DateLastPurchase FROM Customers
WHERE Earnings > 50000
You specify one or more conditions in a
following sections describe ways to filter records with the
•
"Filtering records based on the equality of two values" on page 755
•
"Filtering records based on the likeness of two values" on page 756
•
"Filtering records based on a range of values" on page 757
•
"Filtering records based on a combination of search conditions" on page 758
Filtering records based on the equality of two values
You can filter records in a database based on the equality of a parameter's value with a record
column's value.
Suppose you decide to let users search the database by department. The following logic is required
to build the search results recordset:
•
Check a record in the database table.
•
If the value in the department column of the record is equal to the department name submitted
by the user, then include that record in the search results recordset.
•
Check the next record in the table.
statement:
SELECT
column. To create a recordset containing only the data from
DateLastPurchase
that tells you how much each customer earns. Your
Earnings
"About databases" on page
. To extract all the columns, you would
Customers
statement:
SELECT
clause to filter out records in the database. The
WHERE
WHERE
Limiting the records in a recordset
741.
table: the
Customers
SELECT
clause:
YearBorn
statement
755
Need help?
Do you have a question about the DREAMWEAVER MX 2004-USING DREAMWEAVER and is the answer not in the manual?
Questions and answers