SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. WHERE clause

Text copied!

« Previous
Next »

WHERE clause

May 4, 2023, 3:56 p.m. under SQL

  • Hi! You should check FROM clause post first.

    SQL clause is the specific part of a SQL statement which is used to perform various operations. It can be combined to create more complex queries to retrieve and manipulate data.

    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 :
    SELECT column_name(s)
    FROM table_name
    WHERE conditions;
            

    • Specify the column(s) name after the 'SELECT' keyword.

    • Specify Asterisk (*) symbol to selects all columns from the table after the 'SELECT' keyword.

    • Specify the table name after the 'FROM' keyword.

    • Specify the conditions after the 'WHERE' keyword.

    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.

    WHERE clause

    2. Let's retrieve data from the [Employees] table where the gender is male.

    3. Run below SQL statement :

    SELECT *
    FROM [Employees]
    WHERE Gender = 'Male' ;
            

    4. Above statement will select the data from the [Employees] table where the gender is male.

    WHERE clause

    That's it! You have successfully retrieved the data from [Employees] table where the gender is male.

    Frequently Asked Questions :

    What is the WHERE clause in SQL?

    The WHERE clause in SQL is used to filter records based on specified conditions.

    How to use 2 conditions in WHERE clause in SQL?

    To use 2 conditions in the WHERE clause in SQL, you can combine them using logical operators such as AND or OR.

    What is the use of WHERE clause and having clause?

    The WHERE clause is used to filter rows before grouping in SQL, while the HAVING clause is used to filter groups after grouping.

    What are clauses in SQL?

    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.
    Thank You! You should check GROUP BY clause post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Commands

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    CONCAT function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    GETDATE function

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    CHOOSE function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India support@sqlforgeeks.com

    © 2025 Copyright™ | All Rights Reserved | Privacy Policy