Microsoft KB Archive/825443

= HOW TO: Query Two Tables in the Same Database in FrontPage 2003 =

Article ID: 825443

Article Last Modified on 12/14/2006

-

APPLIES TO


 * Microsoft Office FrontPage 2003

-





For a Microsoft FrontPage 2002 version of this article, see 318281.



IN THIS TASK

 * SUMMARY
 * How to Create a Query to Retrieve Information from Two Tables in a Database
 * REFERENCES



SUMMARY
This article describes a method that you can use to query and retrieve information from two tables in a database in FrontPage 2003. The example that is described in this article uses Microsoft SQL statements to search for data in the Categories and Products tables in the sample Northwind database that match a submitted value for a column that is used in both tables.

back to the top

How to Create a Query to Retrieve Information from Two Tables in a Database
To create a search page and a results page to search for and find specific values from two tables in a database, follow these steps:  Create two new pages that are named Search.asp and Results.asp. To do so, follow these:  Start FrontPage (if it is not already started). On the File menu, point to New, and then in the New task pane, click Blank page. On the File menu, click Save. Specify a location where you want to save the file, type Search.asp in the File name box, and then click Save. On the File menu, point to New, and then in the New task pane, click Blank page.</li> On the File menu, click Save.</li> Specify a location where you want to save the file, type Results.asp in the File name box, and then click Save.</li></ol> </li> Create and configure the form on the search page. To do so, follow these steps: <ol style="list-style-type: lower-alpha;"> In the Folder List, double-click Search.asp to open the page.</li> On the Insert menu, point to Form, and then click Textbox.</li> On the page, right-click the text box that you inserted, and then click Form Field Properties.</li> In the Name box, type ID, and then click OK.</li> On the page, right-click the text box, and then click Form Properties.</li> Under Where to store results, click Send to other, and then click Custom ISAPI, NSAPI, CGI, or ASP Script.</li> Click Options.</li> In the Action box, type results.asp, and then click OK.</li> Click Results.asp, click OK, click OK, and then click OK.</li> On the File menu, click Save.</li></ol> </li> Configure the database query on the results page. To do so, follow these steps: <ol style="list-style-type: lower-alpha;"> In the Folder List, double-click Results.asp to open the page.</li> On the Insert menu, point to Database, and then click Results.</li> <li>Click Use a sample database connection (Northwind), and then click Next.</li> <li>Click Custom query, and then click Edit.</li> <li>Either type or copy and paste the following line to the SQL Statement box:

Select * From Categories,Products Where Categories.CategoryID=::ID:: and Categories.CategoryID=Products.CategoryID

Note This SQL statement returns all the columns from the Categories table and the Products table where the ID that is sent from the Search.asp page matches the CategoryID in the Categories table and the Category ID in the Categories table matches the CategoryID in the Products table.</li> <li>Click OK.</li> <li>Click Next three times.</li> <li>Click Display all records together, click to clear the Add search form check box, and then click Finish.</li> <li>On the File menu, click Save.</li></ol> </li> <li>In the Folder List, double-click Search.asp to open the page.</li> <li>On the File menu, click Preview in Browser, and then click the Web browser that you want to use.</li> <li>In the text box, type 3, and then click Submit.

The columns from the Categories table and the Products table that contain a CategoryID value of 3 are returned.</li></ol>

back to the top

<div class="references_section">