Here is a list of all logical operators available in SQL.

Logical Operators

Operator Description
    ALL It is used to compare a value to a value in another value set.
    AND This operator allows the existence of multiple conditions in an SQL statement.
    ANY This operator is used to compare the any applicable value the condition.
    BETWEEN The BETWEEN operator is used to search for values.
    EXISTS This operator is used to search for the presence of a row in a specified table.
    IN The use of the IN operator is done from a list of values ​​of the value that has been specified.
    LIKE This operator is used to compare a value to similar values using wildcard operator
    NOT This operator used to displays a record if the condition(s) is NOT TRUE
    OR This operator is used to combine multiple conditions in SQL statements.

Examples :

  • ALL 
    Query : 

    SELECT  * FROM customers 
    WHERE Address > ALL (SELECT Address FROM customers
    WHERE Salary > 5800);

    • AND 
      Query : 

      SELECT  * FROM customers 
      WHERE Name = 'Madhur'
      AND customer_Id = 1;

      • ANY 
        Query : 

        SELECT  * FROM customers 
        WHERE Address > ANY (SELECT Address From customers
        WHERE Salary > 5800);

        • BETWEEN
          Query : 

          SELECT  * FROM customers 
          WHERE Salary BETWEEN 5800 AND 8000;

          • EXISTS 
            Query : 

            SELECT  * FROM customers 
            WHERE EXISTS (SELECT Address FROM customers
            WHERE Salary > 5800);

            • IN
              Query : 

              SELECT  * FROM customers 
              WHERE Address IN ('Meerut', 'Delhi');

              • LIKE
                Query : 

                SELECT  * FROM customers 
                WHERE Name LIKE 'An%';

                • NOT NULL
                  Query : 

                  SELECT  * FROM customers 
                  WHERE Name IS NOT NULL;

                  • OR
                    Query : 

                    SELECT  * FROM customers 
                    WHERE Address = 'Meerut'
                    OR Name = 'Kapil';