Results 1 to 2 of 2
  1. #1
    Pernia is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    1

    Question why in operator is very slow in run time?


    Hello,

    This sql query is very slow in runtime and takes a long time to return the result, because of the in operator inside query(because the second table includes more than 10000 records)
    i think i have to change it by using Join commands to increase the speed in runtime.

    but how do i rewrite the following command to turn the Join Command?


    Code:
    Select distinct Fit_R_id from Wels
    where Fit_R_id is not null 
    and 
    id not in
    (
    select Wels_id from Fit
    )
    i tried this :

    Code:
    Select distinct  Fit_R_id from Wels
    left  JOIN Fit ON wels.id = fit.wels_id
    where
    wels.fit_R_id is not null 
    GROUP BY wels.fit_R_id


    but the result was not equal to the first query!
    what is answer?
    thanx

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't think you need both DISTINCT and GROUP BY.

    You want to know which IDs in fit are not in wels? WHERE wels.fit_R_id Is Null

    Did you use the FindUnmatched query wizard?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-25-2012, 04:01 AM
  2. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  3. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  4. in operator
    By pchang in forum Access
    Replies: 1
    Last Post: 01-16-2011, 06:24 AM
  5. Slow Access Loading time
    By alexstoker in forum Access
    Replies: 3
    Last Post: 02-05-2006, 08:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums