User Guide
Chapter 4: Retrieving and Formatting the Data You Want 43
<BODY>
<CFQUERY NAME="GetEmployees" DATASOURCE="CompanyInfo">
SELECT Departments.Department.Name,
Employees.FirstName,
Employees.LastName,
Employees.StartDate,
Employees.Salary
FROM Departments, Employees
WHERE Departments.Department_ID = Employees.Department_ID
<CFIF Form.Department_Name IS NOT "">
AND Departments.Department_Name = ’Form.Department_Name’
</CFQUERY>
<H4>Employee Data Based on Criteia from Form</H4>
4 <CFIF GetEmployees.RecordCount IS "0">
4 No records match your search criteria. <br>
4 Please go back to the form and try again.
4 <CFELSE>
<TABLE>
<TR>
<TH>First Name</TH>
<TH>Last Name</TH>
<TH>Salary</TH>
</TR>
<CFOUTPUT QUERY="GetEmployees">
<TR>
<TD>#FirstName#</TD>
<TD>#LastName#</TD>
<TD>#Salary#</TD>
</TR>
</CFOUTPUT>
</TABLE>
</BODY>
</HTML>
3. Save the file.
4. Return to the form, enter search criteria and submit the form.
5. If no records match the criteria you specified, the message displays.