Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Having vs Where

Posted on 2004-04-03
9
201 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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