Search⌘ K

Logical Operators and Compound Conditions

Explore how to apply logical operators AND, OR, and NOT in SQL to create compound conditions within WHERE clauses. Learn to combine multiple criteria for precise data filtering to generate targeted query results.

Let’s start with generating a list of sales corresponding to a particular product, for example, 'Monitor 21in'.

MySQL
-- Write your query here.

Now, let’s enhance the query. Suppose we want to retrieve sales corresponding to monitors with a sales amount higher than 150. The required condition has two parts:

  1. ProductName = 'Monitor 21in'

  2. SalesAmount > 150

We must formulate the condition in the WHERE clause to satisfy both criteria. To achieve this, we need to find a way to combine the two.

We can employ logical operators for this purpose.  ...