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!
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
OR statements.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
IN ('Val1', 'Val2') whenever checking a column against multiple discrete options. It is significantly faster and cleaner than writing column = 'Val1' OR column = 'Val2'.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.