Results 1 to 5 of 5
  1. #1
    starson79 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jan 2011
    Posts
    9

    Question Faster code? Which one?

    What's faster?



    This...

    WHERE qryEmployeeTrainingHistory.CourseID >0 ;

    Or this...?

    WHERE not(isnull(qryEmployeeTrainingHistory.CourseID)) ;

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Define faster and why is that so important? What is the context for this?
    What exactly is the constraint(criteria)?

    >0; not Null but maybe 0;???

    another where clause to consider
    WHERE qryEmployeeTrainingHistory.CourseID IS NOT NULL;

  3. #3
    starson79 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jan 2011
    Posts
    9
    I was being nosey really.
    I've got a query that extracts all employees who have attended a course.
    Some may not have attended any courses - which means an empty CourseID field (foreign key).
    So the query is filtering on CourseID where only those records that have an entry should be returned. The CourseID starts from 1...[n] so it could never be 0.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by starson79 View Post
    What's faster?

    This...

    WHERE qryEmployeeTrainingHistory.CourseID >0 ;

    Or this...?

    WHERE not(isnull(qryEmployeeTrainingHistory.CourseID)) ;
    the question you should be asking here is: "whats standard??"

    if you ever pass this one to someone, surely they will appreciate reading the former rather than the latter. in terms of speed, I'm pretty sure that the former is about .000000001 nanoseconds faster than the latter.

  5. #5
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    using empty values or testing for empty values is always much slower on any database system I know. So try to avoid it when possible. And for large queries it can really make a difference.
    If you're finetuning for speed, also look at your indexes and connection times.

    succes
    NG

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

Similar Threads

  1. A Faster Search??
    By bladelock9 in forum Forms
    Replies: 0
    Last Post: 03-17-2011, 09:25 AM
  2. Replies: 0
    Last Post: 12-03-2010, 02:17 PM
  3. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  4. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  5. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM

Tags for this Thread

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