Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2006, 12:07 AM
Authorized User
 
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default SQL Join tables help

Hi All,

Im trying to write a SQL statement that will join 2 tables based on a customer has 2 specific products.
eg.

Table 1: Customer

MemberID
MemberName
Email ect

Table 2: Products

ProductID
MID (MemberID of table 1)
ProductName

So how do i write a sql statement to only bring up say cutomers that have a ProductName of "Computers" AND "Laptops" They must have both Computers as an entry in the products table and an entry of Laptops in the relational database.

Your help would be much appreciated.

Tim :)


TDA
__________________
TDA
 
Old January 11th, 2006, 05:34 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tim,

One way would be to use subqueries...
Code:
SELECT MemberID, MemberName FROM Customer
WHERE MemberID IN(SELECT MID FROM Products WHERE ProductName = 'Computers')
AND MemberID IN(SELECT MID FROM Products WHERE ProductName = 'Laptops');
HTH,

Chris


 
Old January 11th, 2006, 04:57 PM
Authorized User
 
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Fantastic!

Thanks chris. exactly what i needed.

Thank you

Tim :)

TDA





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to join all records from both tables? yixchen Access 4 January 4th, 2006 01:36 PM
how to inner join tables gilgalbiblewheel Classic ASP Databases 4 January 31st, 2005 08:04 PM
Join Tables tdaustin Classic ASP Basics 1 May 25th, 2004 07:31 AM
sql & join tables & find a field in multiple table trangd Beginning PHP 2 January 29th, 2004 07:18 PM
Inner Join multiple tables qwprince Classic ASP Databases 5 July 23rd, 2003 02:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.