Lesson 12/100

Tutorials SQL Server Tutorial

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 basicsQueriesAdvanced

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

  1. Insert a few products with different prices and InStock values.
  2. Run the filtered SELECT.
  3. Change AND to OR between price and name and compare.
  4. Filter with IN ('HD-100', 'HD-200') on Sku.
  5. 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.

Mid PDF Detailed
FULL OUTER JOIN: Returns all rows from both tables, with matching rows where?
Short answer: available. If there’s no match, NULL is returned for the missing side. Use case: When you want all records from both tables. Say this in the interview Define — one clear sentence (the short answer above). E…
Mid PDF Detailed
What are the differences between SQL and NoSQL databases?
Short answer: SQL Databases (Relational Databases): These are structured databases that use Structured Query Language (SQL) for defining and manipulating data. Explain a bit more They store data in tables with rows and c…
Mid PDF Detailed
Query Performance:?
Short answer: Use EXPLAIN or QUERY PLAN to analyze query execution times and identify slow queries. Track metrics like response time, execution time, and query throughput. Real-world example (ShopNest) ShopNest adds an i…
Mid PDF Detailed
Start with 1NF: Ensure that the table has no repeating groups or arrays, and each?
Short answer: record has a unique identifier. Real-world example (ShopNest) Product and Category are separate tables (normalized). The order line stores product id + price snapshot—not a giant duplicated product blob. Sa…
Junior PDF Detailed
Define Roles: Define different roles based on business requirements (e.g., admin,?
Short answer: Define Roles: Define different roles based on business requirements (e.g., admin,? is a common interview topic in SQL &amp; Databases. Give a clear definition, then one concrete example. Say this in the int…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

SQL Server Tutorial
Course syllabus

SQL Server Tutorial

SQL — Foundations
SQL — SQL Queries & Clauses
SQL — Joins & Relationships
SQL — Indexing & Performance
SQL — Stored Procedures & Functions
SQL — Transactions & Concurrency
SQL — Advanced SQL Server
SQL — Security & High Availability
SQL — 2022 & Cloud
SQL — Real-World Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details