In this tutorial, we will show you how to create an And OR query in Microsoft Access. When you want to limit the results of a query based on the values in a field, you use query criteria. A query criterion is an expression that Access compares to query field values to determine whether to include the record that contains each value. Creating a query is easy in ms access.
Consider this sample database over here. This table contains the complete details of the customers. What if you want to view the customers of a specific city?
Step 1 – creating query
For that, let’s open the query in the SQL view mode and start by typing the column names which should be displayed. Let’s create a query in access to fetch the records, we will use the select keyword. Let’s choose the first name, Last name, city and the country. Next, we will specify the table name which in this case is the Customers table.
With that done, let’s run the query and a table would be populated displaying only the records of the fields which were specified in the query.
Step 2 – narrowing down search
Now let’s further narrow down the search using the And OR query to populate the results of the customers who are from USA and are located in New York or Chicago.
For that, we will insert a Where clause and specify USA in country with apostrophes. After that, we will insert the AND keyword and within round braces, specify your conditions within apostrophes, separated by OR keyword of course.
With that done, let’s run the query and a table will be displayed showing the customers who are from USA and are present in Chicago or New York.
And that’s it.