DEV Community

Punitha
Punitha

Posted on

SQL Operators

What are SQL Operators?

  • SQL Operators are symbols or keywords used to perform operations on data and compare values in SQL queries.

Arithmetic Operators

  • Arithmetic operators are used to perform mathematical calculations.
Operator     Description

  +           Addition
  -           Substraction
  *           Multiplication
  /           Division
  %           Modulus
Enter fullscreen mode Exit fullscreen mode

Comparison Operators

  • Comparison operators compare two values.
Operator        Description

   =             Equal to
   >             Greater than
   <             Less than
   >=            Greater than or equal to
   <=            Less than or equal to
   <> or !=      Not equal to
Enter fullscreen mode Exit fullscreen mode

Logical Operators

  • Logical operators combine multiple conditions.
Operator    Description

  AND       Both conditions must be true
  OR        At least one condition must be true
  NOT       Reverses the condition
Enter fullscreen mode Exit fullscreen mode

IN Operator

  • The IN operator checks whether a value matches any value in a list.
SELECT *
FROM table_name
WHERE column_table IN (value1, value2);

SELECT *
FROM Employee
WHERE Department IN ('IT','HR')
Enter fullscreen mode Exit fullscreen mode

BETWEEN Operator

  • The BETWEEN operator selects value within a range.
SELECT *
FROM Employee
WHERE Salary BETWEEN 30000 AND 60000;
Enter fullscreen mode Exit fullscreen mode

LIKE Operator

  • The LIKE operator searches for a specific pattern in text.
SELECT *
FROM Employee
WHERE Name LIKE 'p%';
Enter fullscreen mode Exit fullscreen mode

IS NULL Operator

  • The IS NULL operator checks for empty (NULL) values.
SELECT *
FROM Employee
WHERE Email IS NULL;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)