WHERE Clause — Complete Guide
WHERE Clause — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 12 of 100
WHERE Clause
SQL basics → Queries → Advanced
SQL basics · 1 — SELECT · ~6 min · SQL — SQL Queries & Clauses
What is this?
WHERE filters rows before you see them. Only rows matching the condition return. Use =, <>, <, >, LIKE, IN, BETWEEN, AND/OR.
Why should you care?
Without WHERE, a report returns the entire Orders table — slow and wrong. Filters answer “which rows?”
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
SELECT ProductId, Name, PriceInr, InStock
FROM dbo.Products
WHERE InStock = 1
AND PriceInr BETWEEN 1000 AND 10000
AND Name LIKE N'%Head%';
What happened?
- InStock = 1 keeps available items.
- BETWEEN sets a price band.
- LIKE finds names containing Head.
- All three must be true (AND).
Practice next
- Insert a few products with different prices and InStock values.
- Run the filtered SELECT.
- Change AND to OR between price and name and compare.
- Filter with IN ('HD-100', 'HD-200') on Sku.
- Negate with NOT LIKE N'%Head%'.
Remember
WHERE keeps only matching rows. Combine predicates with AND/OR carefully. NULL needs IS NULL / IS NOT NULL.
In-stock catalog filter
Flipkart-style list shows only InStock = 1 inside a price band.
Outcome: Shoppers never click sold-out SKUs from this query.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!