Tutorials Hut

  • SQL Testing




  • SQL Special Operators

    Below are few special SQL operators

      1. IN Operator
      2. LIKE Operator
      3. SQL BETWEEN
    Sql special Operators

    IN Operator

        • It  is a logical operator
        • It allows to test whether a specified value matches any value in a list
        • The IN returns 1 when the search value present within the range otherwise returns 0.

    List all Employee who have Department name is either Finance or IT.

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE DepartmentName = ‘Finance’
    OR DepartmentName = ‘IT’;

    OR

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE DepartmentName IN (‘Finance’, ‘IT’);

    LIKE Operator

        • It  is a logical operator
        • It is used to  search for a specified pattern in a column.
        • The LIKE operator is used in the Where clause of the Select , Update and Delete.

    List all Employee who have Department name  begins with a ‘F’ and has ‘I’ as the second character

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE DepartmentName  LIKE ‘Fi%’;

    List all Employee who have Department name  has ‘T’ as the second character.

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE DepartmentName LIKE ‘_t%’;

    SQL – BETWEEN

        • It  is a logical operator
        • This operator is used to select values within a given range.

    List all Employee who have salary in the range INR 10000 to  INR 20000

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE Salary >= 10000
    AND Salary <= 20000;
    
    
    

    OR

    SELECT EmployeeID, Employee_FirstName,Employee_LastName
    FROM Employee
    WHERE Salary
    BETWEEN 10000 AND 20000;
     
    Recommended Articles:



  • SQL Testing


















  • Leave a Reply

    Your email address will not be published. Required fields are marked *