Where Clause Problem in SQL statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ecohouse

    #1

    Where Clause Problem in SQL statement

    I'm creating a query with a where statement using VBA to create a DAO
    recordset. I've separated the query to make it easier to read. This
    is the query:

    SELECT [test].Race, Count([test].Race) AS CountOfRace
    FROM [test]

    WHERE ((([test].[Name])='BSS 101/OUT 101')
    AND (([test].[Codes])='WORKBOC0104' )
    AND (([test].[Completed Training])=True))

    OR ((([test].[Name])='BSS 101/OUT 101')
    AND (([test].[Codes])='WORKBOC0304' )
    AND (([test].[Completed Training])=True))

    OR ((([test].[Name])='BSS 101/OUT 101')
    AND (([test].[Codes])='WORKPTA0104' )
    AND (([test].[Completed Training])=True))

    OR ((([test].[Name])='BSS 101/OUT 101')
    AND (([test].[Codes])='WORKPTA0304' )
    AND (([test].[Completed Training])=True))

    OR ((([test].[Name])='Common Cents - Fiscal Controls')
    AND (([test].[Codes])='PRCDFIS0104' )
    AND (([test].[Completed Training])=True))

    GROUP BY [test].Race;

    As you can see each where statement uses this same statement:
    AND (([test].[Completed Training])=True

    My question is there an easier way to create this statement without
    having to use "AND (([test].[Completed Training])=True" each time?

    Thanks in advance for the help.
  • Dutchy

    #2
    Re: Where Clause Problem in SQL statement

    WHERE ( (a=b and c=d) or (e=f and g=h) or (i=j and k=l) .... ) and
    trainingcomplet e = true

    --
    Dutchy


    Ecohouse <vindaloo1@netz ero.com> schreef in berichtnieuws
    dde6ca55.040907 1202.17a67379@p osting.google.c om...[color=blue]
    > I'm creating a query with a where statement using VBA to create a DAO
    > recordset. I've separated the query to make it easier to read. This
    > is the query:
    >
    > SELECT [test].Race, Count([test].Race) AS CountOfRace
    > FROM [test]
    >
    > WHERE ((([test].[Name])='BSS 101/OUT 101')
    > AND (([test].[Codes])='WORKBOC0104' )
    > AND (([test].[Completed Training])=True))
    >
    > OR ((([test].[Name])='BSS 101/OUT 101')
    > AND (([test].[Codes])='WORKBOC0304' )
    > AND (([test].[Completed Training])=True))
    >
    > OR ((([test].[Name])='BSS 101/OUT 101')
    > AND (([test].[Codes])='WORKPTA0104' )
    > AND (([test].[Completed Training])=True))
    >
    > OR ((([test].[Name])='BSS 101/OUT 101')
    > AND (([test].[Codes])='WORKPTA0304' )
    > AND (([test].[Completed Training])=True))
    >
    > OR ((([test].[Name])='Common Cents - Fiscal Controls')
    > AND (([test].[Codes])='PRCDFIS0104' )
    > AND (([test].[Completed Training])=True))
    >
    > GROUP BY [test].Race;
    >
    > As you can see each where statement uses this same statement:
    > AND (([test].[Completed Training])=True
    >
    > My question is there an easier way to create this statement without
    > having to use "AND (([test].[Completed Training])=True" each time?
    >
    > Thanks in advance for the help.[/color]


    Comment

    • comp.databases.ms-access

      #3
      Re: Where Clause Problem in SQL statement

      Thanks for the help. That worked for me. I knew I was close, but you
      can see what happens when you use the MS Access Query Builder.



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...