Microsoft KB Archive/318281

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

Article ID: 318281

Article Last Modified on 7/2/2007

-

APPLIES TO


 * Microsoft FrontPage 2002 Standard Edition

-



This article was previously published under Q318281





For a Microsoft FrontPage 2000 version of this article, see 310509.

IN THIS TASK
SUMMARY
 * Create Query with Two Tables

REFERENCES



SUMMARY
This step-by-step article describes how to retrieve information from two tables in a database. The example case uses SQL statements to find data in both tables that matches a submitted value for a column that is used in both tables.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. back to the top

Create Query with Two Tables
To set up using a search form to bring up specific values from two tables, follow these steps:  Create two pages, with the titles Search.asp and Results.asp. Open the Search.asp page. On the Insert menu, point to Form, and then click Textbox. Right-click the text box, and then click Form Field Properties on the shortcut menu. In the Name box, type ID, and then click OK. Right-click the text box, and then click Form Properties on the shortcut menu.</li> Click to select the Send to other check box, click Options, and then type results.asp in the Action box. Click OK twice.</li> On the File menu, click Save.</li> Click Results.asp.</li> On the Insert menu, point to Database, and then click Results.</li> Click to select the Use a sample database connection check box, and then click Next.</li> Click to select the Custom query check box, and then click Edit.</li> In the SQL Statement box, type or paste the following text:

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

NOTE: This returns all the columns from the Categories and Products table where the ID 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> Click OK.</li> Click Next three times.</li> Click to select the Display all records together check box, and then click to clear the Add search form check box.</li> Click Finish.</li> On the File menu, click Save.</li> Open the Search.asp page.</li> On the File menu, click Preview in Browser, and then click OK twice.</li> In the text box, type 3, and then click Submit.</li></ol>

This returns all the columns from Categories and Products with a CategoryID of 3. If any valid ID is submitted, the correct records are returned.

back to the top