Open links in new tab
  1. The WHERE clause in SQL is used to filter records based on specified conditions. It allows you to retrieve, update, or delete only those records that meet the criteria.

    Example

    To select all customers from Mexico:

    SELECT * FROM Customers
    WHERE Country = 'Mexico';
    Copied!

    Syntax

    SELECT column1, column2,
    FROM table_name
    WHERE condition;
    Copied!

    Operators in WHERE Clause

    You can use various operators in the WHERE clause to filter data:

    • =: Equal to

    • >: Greater than

    • <: Less than

    • >=: Greater than or equal to

    • <=: Less than or equal to

    • <> or !=: Not equal to

    • BETWEEN: Between a certain range

    • LIKE: Search for a pattern

    • IN: Specify multiple possible values for a column.

    Example with Multiple Conditions

    To select all offices in the USA with office codes greater than 5:

    SELECT * FROM offices
    WHERE country = 'USA' AND office_code > 5;
    Copied!

    Using IN Operator

    To select cities and countries of offices in the UK or France:

    SELECT city, country
    FROM offices
    WHERE country IN ('UK', 'France');
    Copied!

    The WHERE clause is essential for targeting specific rows in SELECT, UPDATE, or DELETE operations. It is crucial for efficient data manipulation and retrieval.

  1. SQL WHERE Clause - W3Schools

    The WHEREclause is used to filter records. It is used to extract only those records that fulfill a specified condition.
    Text Fields vs. Numeric Fields

    SQL requires single quotes around text values (most database systems will also allow double quotes). However, numeric fields should not be enclosed in quotes:

  2. How to Write a WHERE Clause in SQL - LearnSQL.com

    Nov 9, 2021 · This article covers how to use the SQL WHERE clause in detail, with practical examples using sample data sets.

  3. SQL - WHERE Clause - GeeksforGeeks

    Nov 12, 2025 · The SQL WHERE clause filters rows based on one or more conditions, so your query returns (or modifies) only the records that match. It’s used across SELECT, UPDATE, and DELETE …

  4. How to Use WHERE in SQL with Examples

    Mar 3, 2024 · Understanding the WHERE clause is crucial for anyone looking to harness the full power of SQL. Whether you’re a beginner or looking to brush up on your skills, I’ll guide you through the ins and …

  5. SQL: WHERE Clause - TechOnTheNet

    This SQL tutorial explains how to use the SQL WHERE clause with syntax and examples. The SQL WHERE clause is used to filter the results and apply conditions in a SELECT, INSERT, UPDATE, or …

  6. WHERE (Transact-SQL) - SQL Server | Microsoft Learn

    Nov 18, 2025 · Defines the condition to be met for the rows to be returned. There's no limit to the number of predicates that can be included in a search condition. For more information about search …

  7. SQL Server WHERE Clause

    Summary: in this tutorial, you will learn how to use the SQL Server WHERE clause to filter rows returned by a query. The SELECT statement retrieves all rows from a …

  8. SQL - WHERE Clause - Online Tutorials Library

    The SQL WHERE clause is used to filter records based on specific conditions. It ensures that only the rows meeting the given criteria are affected or returned by a SELECT, UPDATE, or DELETE statement.

  9. SQL WHERE Clause - Tutorial Gateway

    We can use the WHERE clause in UPDATE and DELETE statements. In fact, we must not use those statements (UPDATE and DELETE) without the WHERE clause. …

  10. SQL WHERE [SQL Tutorial with Examples] - DataLemur

    Learn to use the SQL WHERE clause to filter data, so that we only SELECT rows that meet certain conditions.