Thread: SQL Query

Results 1 to 3 of 3
Share This Thread →
  1. #1
    Jaykappy is offline Contributing User ASP Free Beginner (1000 - 1499 posts)
    Join Date
    Feb 2005
    Posts
    1,259
    Rep Power
    35

    SQL Query

    I have the below code that is running a query. IT WORKS great...I have to modify it an confused on the syntax...
    I need to add another varRequestType...

    So the query will read: WHERE varStatus = Planned AND varREquestType1 = Web REquestor OR varRequestType2 = Mobile

    Dim varRequestType1, varRequestType2, varStatus
    varRequestType1 = "Web Requestor"
    varRequestType2 = "Mobile"
    varStatus = "Planned"
    Dim myConn, Recordset,SQLQuery

    SQLQuery = "SELECT * FROM MainGeneral WHERE Requestor = '" & varRequestType1 & "' AND Status = '" & varStatus & "' "


    ???? Do I need () to encapsulate the OR statement from the AND Statement

    SQLQuery = "SELECT * FROM MainGeneral WHERE Status = '" & varStatus & "' AND Requestor = '" & varRequestType1 & "' OR Requestor = '" & varRequestType2 & "' "

  2. #2
    Jaykappy is offline Contributing User ASP Free Beginner (1000 - 1499 posts)
    Join Date
    Feb 2005
    Posts
    1,259
    Rep Power
    35
    This worked

    SQLQuery = "SELECT * FROM MainGeneral WHERE Status = '" & varStatus & "' AND Requestor = '" & varRequestType1 & "' OR Requestor = '" & varRequestType2 & "' "

  3. #3
    June7's Avatar
    June7 is offline Moderator ASP Free Specialist (4000 - 4499 posts)
    Join Date
    Apr 2009
    Location
    The Great Land
    Posts
    4,467
    Rep Power
    649
    Do you need some parens in there like:

    SQLQuery = "SELECT * FROM MainGeneral WHERE Status = '" & varStatus & "' AND (Requestor = '" & varRequestType1 & "' OR Requestor = '" & varRequestType2 & "')"
    I like to know if my suggestion helped you. One way to let me know is by clicking star at bottom left corner of post.
    Debug!Debug!Debug!http://www.cpearson.com/excel/debug.htm

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Replies: 0
    Last Post: August 26th, 2008, 04:45 AM
  2. Replies: 14
    Last Post: February 7th, 2007, 07:31 AM
  3. Replies: 9
    Last Post: March 9th, 2005, 11:28 PM
  4. Replies: 1
    Last Post: October 20th, 2004, 03:50 AM
  5. MAke query and Select Query give diff results
    By AnalystDP in forum Microsoft Access Help
    Replies: 2
    Last Post: June 24th, 2004, 01:36 PM

ASP Free Advertisers and Affiliates