Using AND instead of WHERE in SQL (1 Viewer)

neileg

AWF VIP
Local time
Today, 14:39
Joined
Dec 4, 2002
Messages
5,975
In this thread,
http://www.access-programmers.co.uk/forums/showthread.php?t=97501
Bhanu has used AND in his SQL when I would have used WHERE. Does this matter?

I'm aware that WHERE is preferred over HAVING, is there a similar issue with AND?

You know I'm not formally trained so please help me advance my knowledge!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:39
Joined
Feb 19, 2002
Messages
43,478
I would have used a WHERE clause. Access would consider the join as given to be a non-equi-join and probably wouldn't show it in QBE view. The query might even be non-updatable.
I'm aware that WHERE is preferred over HAVING,
There is no preference, they are different since they are applied at different times.

Only aggregate queries (totals queries) include a having clause. The Where clause is applied prior to aggregation and the Having clause is applied afterwards. Therefore a query might contain both. A Where clause to select a date range for example and a having clause to select the account with the most orders or the highest dollar value for the period defined by the date range.
 

neileg

AWF VIP
Local time
Today, 14:39
Joined
Dec 4, 2002
Messages
5,975
Thanks, Scott, Pat. You have shone a light into my vast cave of ignorance.
 

Users who are viewing this thread

Top Bottom