Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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 June 10th, 2003, 01:58 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select records NOT in table

Hi,
I have 2 tables:
tblClient:
clientID
firstName
: :
: :

tblPortfolio:
clientID
plotID


I want to select a list of clients from tblClient who are not featured in tblPortfolio. Any ideas?

Thanks
Dave
 
Old June 10th, 2003, 03:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is a job for an outer join:
Code:
SELECT T1.ClientID
   FROM tblClient T1
      LEFT OUTER JOIN tblPortfolio T2 ON T1.clientID=T2.clientID
WHERE T2.clientID IS NULL;
The idea is that an OUTER JOIN like this will pair every row in the first table with matching entries in the second, based on the ON condition. There will be a row for every entry in the first table and if there is no matching entry in the second, then the columns of the second table will have their values set to NULL. The WHERE clause selects those nonmatching clients - that is, the second table's clientID is null.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old June 10th, 2003, 04:04 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Jeff

Dave





Similar Threads
Thread Thread Starter Forum Replies Last Post
how i can select this records dhua SQL Server 2000 0 February 8th, 2007 11:56 PM
select records from excel androoo VB How-To 1 March 22nd, 2005 06:39 AM
select ONLY records 51-100 in a MySQL table crmpicco Classic ASP Databases 2 February 24th, 2005 07:21 AM
copy and append records from table-A to table B bhunter Access 6 March 9th, 2004 02:02 PM
thousands records enter one table to another table mateenmohd SQL Server 2000 3 July 17th, 2003 07:52 AM





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