Home

Microsoft Access Data Analysis: Disjunction

 

Introduction

Logical disjunction is performed using the OR operator called. Besides the SELECT statement, the formula to use is:

WHERE Expression1 OR Expression2

The WHERE and the OR keywords are required. Each expression is in the form:

FieldName Operator Value

This means that you must specify a column, the operator that performs the filtering, and the value applied to the column. Here is an example:

SELECT Title, Director, CopyrightYear, Rating, Length, Format, [Wide Screen]
FROM   Videos
WHERE (Rating = "Unrated") OR (Rating = "R");

Here is another example: 

SELECT 	Properties1.[Property #],
	Properties1.[Property Type], 
	Properties1.City, 
	Properties1.State, 
	Properties1.Bedrooms, 
	Properties1.Bathrooms, 
	Properties1.Condition, 
	Properties1.[Market Value]
FROM 	Properties1
WHERE 	(((Properties1.State)="VA")) OR (((Properties1.State)="MD"));

Here is an example that also uses an AND operator
 

SELECT 	Properties1.[Property #], 
	Properties1.[Property Type], 
	Properties1.City, 
	Properties1.State, 
	Properties1.[ZIP Code], 
	Properties1.Bedrooms, 
	Properties1.Bathrooms, 
	Properties1.Stories, 
	Properties1.[Year Built], 
	Properties1.Condition, 
	Properties1.[Market Value]
FROM 	Properties1
WHERE 	(((Properties1.[Property Type])="single family") AND 
	 ((Properties1.[ZIP Code]) Between 20850 And 20920)) OR 
	 (((Properties1.[Property Type])="townhouse"));

Here is another example: 

SELECT 	Properties1.[Property #], 
	Properties1.[Property Type], 
	Properties1.City, 
	Properties1.State, 
	Properties1.[ZIP Code], 
	Properties1.Bedrooms, 
	Properties1.Bathrooms, 
	Properties1.Stories, 
	Properties1.[Year Built], 
	Properties1.Condition, 
	Properties1.[Market Value]
FROM 	Properties1
WHERE 	((Properties1.[Property Type] = "single family") OR 
	 (Properties1.[Property Type] = "townhouse")) AND 
	 (Properties1.[ZIP Code] Between 20850 And 20920);
 
 

Home Copyright © 2008 FunctionX, Inc.