SQL Logical operators | SQL Tutorial and Query Example

Text copied!

SQL Logical operators


  • Overview of SQL logical operators :
    1. AND :

    It is a operator that returns 'TRUE' if both or all the specified conditions are true in 'WHERE' clause.

    2. OR :

    It is a operator that returns 'TRUE' if any or at least one condition is true in 'WHERE' clause.

    3. NOT :

    It is a operator that reverses or negates the conditions in 'WHERE' clause.

    • AND 
    • OR 
    • NOT
            
    To enhance your understanding of 'SQL operators', be sure to check out our next tutorial.
    SQL Logical operators
    SELECT * 
    FROM [Employees]
    WHERE Gender = 'Female' AND Salary > 5000;
            
    SQL Logical operators
    SELECT * 
    FROM [Employees]
    WHERE Gender = 'Female' OR Salary > 5000;
            
    SQL Logical operators
    SELECT * 
    FROM [Employees]
    WHERE NOT Gender = 'Male';
            
    SQL Logical operators

    Frequently Asked Questions :

    Logical operators in SQL are used to combine or manipulate conditions in WHERE clauses, such as AND, OR, and NOT.
    SQL logic refers to the principles and rules governing the manipulation and retrieval of data using SQL commands and statements.
    The unique logical operator in SQL is XOR (Exclusive OR), which returns true if only one of the operands is true.
    Logical operators in SQL are symbols or keywords used to perform logical operations like AND, OR, NOT, XOR, etc., to filter data based on specified conditions.