beautypg.com

Define parameters in a sql statement (php), Create sql queries using the database items tree, Example: selecting a table – Adobe Dreamweaver CC 2015 User Manual

Page 578

background image

571

Dynamic sites, pages and web forms

Last updated 6/3/2015

Define parameters in a SQL statement (PHP)

Define parameters in a SQL statement; the default value is the value that the parameter should use if no run-time value
is returned.

1

Enter a parameter name in the Name box.

2

Enter a default value for the parameter in the Default Parameter box.

3

Enter a run-time value for a parameter in the Run-time Value box, and click OK.

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