• Home
  • SQL WHERE Clause

    The WHERE clause in SQL is used to filter records based on specific conditions. It allows you to retrieve only the rows that meet the specified criteria. The basic syntax of the WHERE clause is as follows:

    sql
    SELECT column1, column2, ...
    FROM table_name
    WHERE condition;

    Here, "condition" represents the condition or set of conditions that the data must satisfy for it to be included in the result set. You can use various comparison operators and logical operators in the condition to create complex filtering conditions.


    Here are some examples to demonstrate the usage of the WHERE clause:

    1. Retrieve records where the age is greater than 30:

    sql
    SELECT *
    FROM employees
    WHERE age > 30;

    2. Retrieve records where the department is 'Sales' and the salary is greater than 5000:

    sql
    SELECT *
    FROM employees
    WHERE department = 'Sales' AND salary > 5000;

    3. Retrieve records where the name starts with 'J' and the age is between 25 and 35:

    sql
    SELECT *
    FROM employees
    WHERE name LIKE 'J%' AND age BETWEEN 25 AND 35;

    4. Retrieve records where the department is 'Marketing' or 'Finance':

    sql
    SELECT *
    FROM employees
    WHERE department = 'Marketing' OR department = 'Finance';

    These are just a few examples of how you can use the WHERE clause to filter data in SQL. You can combine multiple conditions using logical operators like AND and OR to create more complex filtering conditions.



    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





     PreviousNext