SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL 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 ASP Free Forums Sponsor:
  #1  
Old October 23rd, 2002, 05:47 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
optimize the select Query

<i><b>Originally posted by : Raman Garg (mrgargraman@yahoo.com)</b></i><br />I have two tables tblAddressBook and tblSalesTransaction. I want all records from tblAddressBook which are not in tblSalesTransaction. I have written following Query. I want to optimize this.<br /><br /><br />SELECT distinct tblAddressBook.ABAN8 FROM tblAddressBook Where tblAddressBook.ABAN8 not in (<br />SELECT distinct tblAddressBook.ABAN8<br />FROM tblAddressBook INNER JOIN tblSalesTransaction ON tblAddressBook.ABAN8 = tblSalesTransaction.SDAN8;<br />)<br />

Reply With Quote
  #2  
Old February 11th, 2003, 03:34 PM
jon.Clarke jon.Clarke is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 11 jon.Clarke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
As the field in the address table that you are checking is unique is the same as the one you are joining on for the sales transaction then I'd just check to see if the address is not in the sales table... this saves having to do a join which will help speed things up...<br><br>SELECT distinct tblAddressBook.ABAN8 <br>FROM tblAddressBook <br>WHERE tblAddressBook.ABAN8 NOT IN (<br> SELECT DISTINCT tblSalesTransaction.SDAN8<br> FROM tblSalesTransaction)

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > optimize the select Query


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 4 hosted by Hostway
Stay green...Green IT