Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 10th, 2003, 01:58 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old June 10th, 2003, 03:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
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
Reply With Quote
  #3 (permalink)  
Old June 10th, 2003, 04:04 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Jeff

Dave
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 03:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.