FP98: How to Search Using LIKE In SQL Statement For IDC or ASP

ID: Q194677


The information in this article applies to:


SUMMARY

This article describes how to search a database using the LIKE parameter in a Structured Query Language (SQL) statement in either the Internet Database Connector (IDC) Wizard or the Database Region Wizard of FrontPage.

This article assumes you have a basic knowledge of how to query a database using Active Server Pages (ASP), Internet Database Connector (IDC) or Hypertext Markup Language Extension (HTX) technologies in FrontPage.

For additional information about database connectivity with ASP or IDC/HTX, please see the following articles in the Microsoft Knowledge Base:

Q180405 FP98: Sample ASP Wizard Available for Download

Q175770 FP98: How to Post Information to a Database Using ASP

Q174407 FP98: How to Create IDC/HTX Files in FrontPage 98

Q161155 FP97: How to Make a Web Page Display Data from a Database


MORE INFORMATION

When used in a search, the LIKE parameter generates a result set based on a minimum amount of information typed into the form field of a HyperText Markup Language (HTML) form. For example, if you type "mic" (without the quotation marks) in the form field, the results may include Microsoft, microphone, microwave, and so forth.

To use the LIKE parameter in a SQL statement in FrontPage, start the IDC wizard or the Database Region Wizard, and use the following syntax in the SQL statement


   SELECT * FROM <Table Name> WHERE <Database Field> LIKE '%%%<HTML
   Field>%%%' 
where <Table Name> is the name of a table in the database, <Database Field> is a field in that table, and <HTML Field> is the name of an HTML form field on an HTML document (usually a text box).

The extra percentage signs around the HTML form field name act as wild cards so that the LIKE string can match multiple records. For example, if you entered this SQL code

   SELECT * FROM Employees WHERE Email Like '%%%Email%%%' 
And type volcano in the form field, all records that contain volcano.com in the email field are returned.

NOTE: This example works with the Volcano.mdb file that is included with the ASP sample Web. For additional information please see the following article in the Microsoft Knowledge Base:
Q180405 FP98: Sample ASP Wizard Available for Download
If you use this query and the form field is blank when you submit the form, all records in the database will be returned. However, you can require that a value be entered before the form is submitted by using form field validation.

Additional query words: 98 SQL ASP IDC Database LIKE


Keywords          : fpscript 
Version           : WINDOWS:
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: July 28, 1999