WHERE

G

Guest

Can somebody please explain how WHERE works and under what circumstances it
should be used? I've found that it works for some of the things I want, but
I would like to know if there is a way to know when to use WHERE.

Thanks
Sue

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...e27b429272&dg=microsoft.public.access.queries
 
J

Jeff Boyce

Sue

I can't tell from your description, but suspect you are trying to write SQL
statements to work as queries.

In MS Access, you can create queries in design view and not need to focus on
the SQL (unless you wish to).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John Spencer

WHERE in a query applies criteria against fields to return records that
match the criteria.

Basically when you don't want ALL the records returned, you use a where
clause.

This starts to get complicated when you use multiple criteria.
You can say that all the criteria must be met
(WHERE A = 1 and B=2)
or you can say that any of the criteria must be met
(WHERE A=1 or B=2)

or you can make it more complicated and combine things
WHERE A=1 AND (B=2 or C=5)
So a record is returnd if A =1 and if B=2 or C=5.

Move the parenthese
WHERE (A=1 AND B=2) or C=5)
and a record is returned if a=1 and b=2 or if C = 5

That very, very lightly scratches the surface of what where does in a
query.

There are multiple operators you can use - equal, not equal, less than,
more than, and like are the more common ones.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top