Dreamweaver

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 table

This 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.

  1. Expand the Tables branch to display all of the tables in the selected database.
  2. Select the Employees table.
  3. Click the Select button.
  4. Click OK to add the recordset to the Bindings panel.

Example: Selecting specific rows from a table and ordering the results

The 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
  1. 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.
  2. 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.

  3. Place the insertion point after WHERE emplJob in the SQL text area and type ='varJob' (include the equal sign).
  4. 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").
  5. Click OK to add the recordset to the Bindings panel.