We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Logical Operators – AND

We often need to use multiple conditions to retrieve the exact information we want. We can begin to structure much more complex queries by using multiple conditions together to narrow down the search results of our query.

The logical AND operator can be used to narrow down our result sets even more!

AND Operator

SELECT product_name, quantity, shipment_status
FROM products
WHERE shipment_status = 'pending'
  AND quantity BETWEEN 0 and 10;

This only retrieves records where both the shipment_status is "pending" AND the quantity is between 0 and 10.

Comparison Operators

All of the following operators are supported in SQL. The = is the main one to watch out for – it's not == like in many other languages! SQLite does allow for ==, but it's not a good habit to get into, as other dialects of SQL will not recognize == as valid syntax.

  • =
  • <
  • >
  • <=
  • >=
  • <> or !=

Assignment

The legal restrictions in Canada have changed! The way we have to handle Canadian minors' CashPal transactions is more tightly regulated. We need to find all of those users, so we can see how many this change affects!

Write a query that retrieves all columns for users in the users table who are from Canada (CA) and under the age of 18.