← Articles
MSSQLTips.com · March 01, 2023

How to use the SQL WHERE Clause with Examples

Using the AdventureWorks2017 sample database, this tutorial demonstrates how the WHERE clause restricts rows retrieved, inserted through a SELECT statement, updated or deleted in SQL Server. Examples progress from simple equality predicates to conditions involving multiple columns and related tables.

The article covers AND and OR, IN, EXISTS and NOT EXISTS, NULL checks, filtering joined tables, LIKE patterns and BETWEEN ranges. It illustrates how subqueries and table aliases can express more specific filtering requirements, providing a practical reference for writing T-SQL statements that target the intended records.

Visit original source ↗

Search website

Type to search the portfolio.

↑ ↓ Navigate · Enter to open · Esc to close