Solved

Having vs Where

Posted on 2004-04-03
9
209 Views
Last Modified: 2009-12-16
Hi,

I know the basic difference between HAVING and WHERE.  In terms of the speed, does it make a difference?  Thanks
0
Comment
Question by:mcrmg
  • 4
  • 4
9 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 10751216
Hmm, I think not, but Access surprised me more then once :-)

Just create a small test module to execute a HAVING and a WHERE groupby query a few 1,000 times in a loop with a save time and a print of the time difference when ready.
Make sure to run it several times as the system's workload can make a single measurement unreliable.

Nic;o)
0
 

Author Comment

by:mcrmg
ID: 10751266
I was wondering if you could help me with this.  Thanks
0
 
LVL 54

Accepted Solution

by:
nico5038 earned 180 total points
ID: 10751295
Where's the problem?

Just create a function like:

Function fncTestTime()

Dim dtm As Date

dtm = Time()

For intI = 1 To 1000
   CurrentDb.Execute ("having query")
Next

Debug.Print "Having duration: " & Date - dtm

dtm = Time()

For intI = 1 To 1000
   CurrentDb.Execute ("where query")
Next

Debug.Print "Where duration: " & Date - dtm

End Function


Nic;o)
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:mcrmg
ID: 10751297
I was missing the "duration" Part...  Thank you
0
 

Author Comment

by:mcrmg
ID: 10751319
Hi,

I run this and it says " expect a function or variable", I thought I need to assign it to a rs??

Set rs = CurrentDb.Execute("SELECT * FROM Loan")
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10751329
Try just:

 CurrentDb.execute("SELECT * FROM Loan")

Nic;o)
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 100 total points
ID: 10752060
I think this won't work. You can not execute a select query

       <CurrentDb.execute("SELECT * FROM Loan")>

Try it this way
Dim strSQL as String
strSQL="Select * From Loan"

Set rs = CurrentDb.OpenRecordset(strSQL)

0
 

Author Comment

by:mcrmg
ID: 10752160
Yes, it works fine.  How can I call a query that I built in query builder?  Thx
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10752241
Just use the name in:
Set rs = CurrentDb.OpenRecordset("<queryname>")

Nic;o)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question