MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2004, 12:45 PM
JsonTerre1 JsonTerre1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Buffalo NY, USA
Posts: 29 JsonTerre1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to JsonTerre1
Select from one table which is not in another

I am trying to select records from a vendor table which is not in a vendor delete table.

I am not allowed to add columns to any of the tables and i am not allowed to delete any. so i decided to make a delete table and select everything that is not in is.

this is what i have and i have to base the select statment on 4 colums rather then one ID as usuall.

Can someone tell me what is wrong here and help me with this.

SELECT TOP 100 PERCENT CompanyID, DivisionID, DepartmentID, VendorID, VendorName, AccountNumber
FROM dbo.VendorInformation
WHERE (SELECT *
FROM dbo.VendorsDeleted
WHERE dbo.VendorInformation.VendorID <> dbo.VendorsDeleted.VendorID AND
dbo.VendorInformation.DepartmentID <> dbo.VendorsDeleted.DepartmentID AND
dbo.VendorInformation.DivisionID <> dbo.VendorsDeleted.DivisionID AND
dbo.VendorInformation.CompanyID <> dbo.VendorsDeleted.CompanyID)
ORDER BY VendorName

Reply With Quote
  #2  
Old July 27th, 2004, 01:25 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,775 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 15 h 59 m 41 sec
Reputation Power: 37
Code:
SELECT CompanyID, DivisionID, DepartmentID, VendorID, VendorName, AccountNumber
FROM dbo.VendorInformation
WHERE not exists (select * from
FROM dbo.VendorsDeleted
WHERE dbo.VendorInformation.VendorID = dbo.VendorsDeleted.VendorID AND
dbo.VendorInformation.DepartmentID = dbo.VendorsDeleted.DepartmentID AND
dbo.VendorInformation.DivisionID = dbo.VendorsDeleted.DivisionID AND
dbo.VendorInformation.CompanyID = dbo.VendorsDeleted.CompanyID)
ORDER BY VendorName

Reply With Quote
  #3  
Old July 27th, 2004, 01:50 PM
JsonTerre1 JsonTerre1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Buffalo NY, USA
Posts: 29 JsonTerre1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to JsonTerre1
Thanks

Thank you. That worked perfectly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Select from one table which is not in another


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway