Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
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 One-Line Text Box.
- 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.
- Click to select the Send to other check box, click Options, and then type results.asp in the Action box. Click OK twice.
- On the File menu, click Save.
- Click Results.asp.
- On the Insert menu, point to Database, and then click Results.
- Click to select the Use a sample database connection check box, and then click Next.
- Click to select the Custom query check box, and then click Edit.
- In the SQL Statement box, type or paste the following text:
Select * From Categories,Products Where Categories.CategoryID=::ID:: and Categories.CategoryID=Products.CategoryIDNOTE: 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.
- Click OK.
- Click Next three times.
- Click to select the Display all records together check box, and then click to clear the Add search form check box.
- Click Finish.
- On the File menu, click Save.
- Open the Search.asp page.
- On the File menu, click Preview in Browser, and then click OK twice.
- In the text box, type 3, and then click Submit.