WHERE clause | SQL Tutorial and Query Example

Text copied!

WHERE clause


  • WHERE clause :

    WHERE clause is used to specify condition(s) to filter data in the database. It is often used with other clauses such as 'SELECT', 'FROM' and 'ORDER BY' etc. to retrieve, specify table, sort and manipulate data.

    The syntax of the WHERE clause generally looks like this :
    Here's an example of how you might use the WHERE clause :

    1. Suppose we have a table called [Employee] table with gender column containing male and female values.

    SELECT column_name(s)
    FROM table_name
    WHERE conditions;
            
    WHERE clause
    SELECT *
    FROM [Employees]
    WHERE Gender = 'Male' ;
            
    WHERE clause

    Frequently Asked Questions :

    The WHERE clause in SQL is used to filter records based on specified conditions.
    To use 2 conditions in the WHERE clause in SQL, you can combine them using logical operators such as AND or OR.
    The WHERE clause is used to filter rows before grouping in SQL, while the HAVING clause is used to filter groups after grouping.
    Clauses in SQL are components of a query that specify criteria for the retrieval or manipulation of data, such as SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY.