SQLMarrow / Course Academy Experience

SQL & Databases Masterclass Course

Welcome to the ultimate postgresql tutorial for beginners 2026. Work through interactive sql practice problems with solutions, master our comprehensive sql window functions tutorial modules, and prepare for tough sql interview questions at Google and Amazon entirely in your browser. Claim your course completion XP and build production-ready database mastery today!

COURSE PROGRESS
0%
0 of 40 Modules Solved
COURSE SYLLABUS
40 Lessons
LESSON WORKSPACEBeginner

SQL Lesson 3: Queries with constraints (Pt. 2)

Introduction & Core Concept

While mathematical operators handle numbers, auditing and customer support frequently require filtering text and string columns. SQL provides powerful text-matching tools:

  • LIKE: Performs pattern matching. The percent sign (%) acts as a wildcard matching zero or more characters.
  • IN (val1, val2, ...): Acts as a concise shorthand for multiple OR equality statements. Matches any value inside the list.
  • NOT: Reverses or negates any boolean comparison expression.
  • Why & Where We Use It
  • Why We Use It: Allows analysts to perform fuzzy searches, search for partial names, or filter against lists of approved department codes without writing dozens of verbose OR statements.
  • Where We Use It: Search bars, fraud detection filters, and categorizing textual survey responses.
  • Real-World Example

    A customer service representative is trying to look up a customer whose last name is "Smith" or "Smithson", but they can only remember that the last name starts with "Smi". They run a query with WHERE name LIKE '%Smi%'.

    Best Practices: What to Do & What NOT to Do
  • What to Do: Use IN ('Val1', 'Val2') whenever checking a column against multiple discrete options. It is significantly faster and cleaner than writing column = 'Val1' OR column = 'Val2'.
  • What NOT to Do: Avoid putting leading wildcards at the very start of a LIKE pattern (e.g., WHERE name LIKE '%son') if you have millions of rows. Leading wildcards prevent the database from using B-Tree indexes, forcing a slow full table scan!
  • Syntax & Pro Tips
  • name LIKE 'S%' ➔ Matches names starting with 'S'.
  • name LIKE '%Scott%' ➔ Matches names containing 'Scott' anywhere inside the string.
  • category IN ('Electronics', 'Furniture') ➔ Matches items belonging to either category.
  • Interactive Sandboxed Terminal (Preloaded DB Schema: SHOPMART)
    SQL Query WorkspaceSQLite v3.45 (WASM Mode)
    QUICK INSERT:
    1