Dreamweaver CS4 Resources
|
Create SQL queries using the Database Items tree
Instead of manually typing SQL statements
into the SQL box, you can use the Database Item’s point-and-click
interface to create complex SQL queries. The Database Items tree
lets you select database objects and link them using the SQL SELECT,
WHERE, and ORDER BY clauses. After you create a SQL query, you can define
any variables using the Variables area of the dialog box.
The next
two examples describe two SQL statements and the steps for creating them
using the advanced Recordset dialog box’s Database Items tree.
Example: Selecting a tableThis example selects the entire contents of
the Employees table. The SQL statement defining the query appears
as follows:
SELECT * FROM Employees
To
create this query, follow these steps.
- Expand the Tables branch to display all of the
tables in the selected database.
- Select the Employees table.
- Click the Select button.
- Click OK to add the recordset to the Bindings panel.
Example: Selecting specific rows from a table and ordering the resultsThe following example selects two rows from
the Employees table, and selects the job type using a variable that
you must define. The results are then ordered by employee name.
SELECT emplNo, emplName
FROM Employees
WHERE emplJob = 'varJob'
ORDER BY emplName
- Expand the Tables branch to display all of the
tables in the selected database; then expand the Employees table
to display the individual table rows.
- Build the SQL statement as follows:
Select emplNo, and click
the Select button.
Select emplName, and click the
Select button.
Select emplJob, and click the Where
button.
Select emplName, and click the
Order By button.
- Place the insertion point after WHERE emplJob in
the SQL text area and type ='varJob' (include the
equal sign).
- Define the variable 'varJob' by clicking
the Plus (+) button in the Variables area and entering the following
values in the Name, Default Value, and Run-Time Value columns: varJob, CLERK, Request("job").
- Click OK to add the recordset to the Bindings panel.
|