473,503 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Nov 13 '05 #1
2 1524
WHERE ( (a=b and c=d) or (e=f and g=h) or (i=j and k=l) .... ) and
trainingcomplete = true

--
Dutchy
Ecohouse <vi*******@netzero.com> schreef in berichtnieuws
dd**************************@posting.google.com...
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.

Nov 13 '05 #2
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!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
3575
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
2
188919
by: Largo SQL Tools | last post by:
Can anyone tell me if it's possible to use a Case statement in a Where clause, and if so, the proper syntax? J.R. Largo SQL Tools The Finest Collection of SQL Tools Available...
4
25570
by: Tom Walker | last post by:
I cannot get the WHERE statement to work correctly unless I use a literal with the LIKE. I want to use a working storage data name so that I can vary the WHERE statement. Example that works: ...
1
1107
by: Justin | last post by:
I have a variable string "myvar" and I need to pass it to the WHERE clause of a SELCET statement I have tried myvar.ToString(), Cint, parse and convert. The Select statement works fine when I...
6
10892
by: Altman | last post by:
I am playing around with making a dataset with the designer in vb.net 2005. I realize you can add parameters to select statement and then filter off of those parameters. What I would like to do...
7
3367
by: Swinky | last post by:
Mr. Browne's copy code on his web site has saved me. I have been struggling to copy a record with several related sub-form tables. I found code on his web site that copies a sub-form table,...
2
10726
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
8
3464
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
5
2647
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
6
4161
by: Plissskin | last post by:
I need to create an "ad-hoc" filtering page in a web app we are building. The page would display a number of drop down lists, text boxes, and radio lists and allow the user to select (enter) some...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.