Back to DATA RETRIEVAL & FILTERING

WHERE CLAUSE

Understand `WHERE` Clause Basic Filtering and Logical Operators.

13 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. WHERE vs SELECTThe WHERE clause filters rows, whereas the SELECT statement filters columns.
  2. Basic Comparison OperatorsThe equal sign (=) is a comparison operator used to find exact matches.
  3. Greater Than and Less ThanComparison operators like > and < exclude the boundary value, while >= and <= include it.
  4. NOT Equal OperatorThe != (exclamation point and equal sign) operator returns rows that do not match the specified value.
  5. Filtering Date Data TypesDates can be filtered using comparison operators, typically formatted as 'YYYY-MM-DD' in quotes.
  6. Logical Operator AND/ORLogical operators AND and OR allow combining multiple conditional statements in the WHERE clause.
  7. Precedence and ParenthesesParentheses enforce order of operations (PEMDAS) to isolate and group complex conditions.
  8. LIKE Statement and WildcardsThe LIKE statement searches for patterns using the % (any characters) and _ (single character) wildcards.
PDF notes

Frequently asked questions

Does the WHERE clause filter columns or rows?

The WHERE clause filters rows (records) based on conditions, while the SELECT statement filters columns.

How do I filter by date?

Use comparison operators (like >, <, =) and ensure the date is formatted as 'YYYY-MM-DD' and enclosed in quotes.

Why didn't my query include the exact salary I specified (e.g., 50,000)?

If you used > (greater than), the exact value is excluded. Use >= (greater than or equal to) to include it.

What is the difference between % and _ in LIKE?

% matches any sequence of zero or more characters, while _ matches exactly one single character.