Using AND/OR logic in conditions
Using several conditions in a query is a very common scenario because, in many cases, we are required to build a query with a set of filters to get the most accurate results.
Conditions in queries can use the AND or OR operators.
A relation that creates an intersection between conditions is called an AND relation. This means all the common rows for Filter A and Filter B will be retrieved.
Have a look at the following figure. Here, the data retrieved by the AND operator can be described as the dark area in the middle. It is the common intersected area.
For instance, if our query has a set of two conditions: year equal to 2014 AND product name equal to smart phones and no smart phones were sold in 2014, the query won't return any results since the conditions didn't have common rows.
The relation between conditions using an OR operator is a relation that uses a union operator, meaning there is no need for the conditions to have common rows. If any one of the conditions...