Results 1 to 3 of 3
  1. #1
    Johanb26 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    25

    Creating an SQL query with AND and Or clauses.

    Good day

    Can somebody please assist me I have the following query:


    Code:
    WHERE client_division = 'DivisionA' OR client_division = 'DivisionB' OR client_division ='DivisionC' and results_date >= #01/01/2014#;
    What I want the query to return is only the selected divisions and their results from 01/01/2014 and upwards. But with my query as above I get all the selected divisions and the date is ignored, so the query displays results from 2013 and back.

    Please help me.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    try putting the 'OR' part of your query in brackets

    Code:
    WHERE (client_division = 'DivisionA' OR client_division = 'DivisionB' OR client_division ='DivisionC') and results_date >= #01/01/2014#
    you can also write it this way

    Code:
    WHERE client_division  IN ('DivisionA', 'DivisionB' , 'DivisionC') and results_date >= #01/01/2014#

  3. #3
    Johanb26 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    25
    Thank YOU!!!

    It worked and the IN clause is a wonderful piece of advice

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

Similar Threads

  1. Need help creating a query
    By MeginMurphy in forum Queries
    Replies: 3
    Last Post: 04-25-2014, 12:38 PM
  2. Creating a query
    By aubtiger14 in forum Queries
    Replies: 3
    Last Post: 12-09-2013, 07:39 PM
  3. Creating a query in VBA help?
    By offie in forum Programming
    Replies: 9
    Last Post: 07-15-2013, 01:54 PM
  4. Replies: 3
    Last Post: 01-01-2013, 06:22 PM
  5. need help with creating a certain query
    By tosho in forum Queries
    Replies: 4
    Last Post: 03-30-2012, 02:24 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