In order to really
understand how to create complex queries, we need a basic knowledge
of Boolean Algebra. But a word of advice to those of you who are
not that mathematically oriented and who shudder at the thought
of anything related to Algebra – don’t panic. Boolean Algebra is
not that difficult to grasp and makes perfect sense once you’ve
got the basics.
Boolean Algebra is simply a
way of rephrasing a complicated logical statement into a series
of simpler AND, OR and NOT conditions without
changing its meaning. The rules of Boolean Algebra are straight-forward,
and can be applied to any logical expression. The notational system
was developed by the English mathematician George Boole to permit
an algebraic manipulation of logical statements. Today, all computers
employ Boole's logic system - using microchips that contain thousands
of tiny electronic switches arranged into logical ‘gates’ that produce
predictable and reliable conclusions.
For the purposes of trying to
understand the 3 Boolean operators, namely AND, OR and NOT, let’s
look at 2 simple sets of data, namely
Blue
Set (Dark Shading): Contacts whose Job Title = (is exactly) Marketing
Manager
Yellow
Set (Light Shading): Contacts whose Country = (is exactly) United
States of America
Boolean
AND

When the AND operator
is used to join the 2 sets, the results retrieved will contain both
Blue and Yellow information. So in this case you would only get
contacts that are Marketing Managers AND have United States
of America as their country. This would be the Green set shown above.
Boolean
OR

When the OR operator
is used to join the 2 sets, the results retrieved will contain either
Blue, or Yellow, or Blue and Yellow information together. So in
this case you would get contacts that are Marketing Managers or
have United States of America as their country, or both. This would
be the entire set of Blue, Green and Yellow shown above.
Boolean
NOT

When 2 conditions are combined
with a NOT operator, the results retrieved will contain only
Blue exclusively. So in this case you would get contacts that are
Marketing Managers but do not have United States of America as their
country. This would be the Blue set above.
|