Geek Slack

Getting Started with SQL Server
    About Lesson


    SQL WHERE Clause


    SQL WHERE Clause

    The WHERE clause is used to filter records based on specified conditions in SQL queries. It allows you to specify criteria to select only the rows that meet those conditions.

    Basic WHERE Clause:

    SELECT *
    FROM customers
    WHERE country = 'USA';

    This query selects all columns from the “customers” table where the “country” column has the value ‘USA’.

    WHERE Clause with Comparison Operators:

    SELECT *
    FROM products
    WHERE price > 100;

    This query selects all columns from the “products” table where the “price” column is greater than 100.

    WHERE Clause with Logical Operators:

    SELECT *
    FROM orders
    WHERE status = 'shipped' AND total_amount > 1000;

    This query selects all columns from the “orders” table where the “status” column is ‘shipped’ and the “total_amount” column is greater than 1000.

    The WHERE clause can be combined with various operators and functions to create complex conditions for filtering data.