SQL Operators List
SQL operators are symbols or keywords used to perform operations on data, such as comparisons, arithmetic calculations, logical evaluations, and more. Knowing the common operators helps you write precise and efficient queries.
🔹 Categories of SQL Operators
Category | Operators | Purpose |
---|---|---|
Arithmetic | + , - , * , / , % | Basic math operations |
Comparison | = , <> or != , < , > , <= , >= | Compare values (equal, not equal, less, greater, etc.) |
Logical | AND , OR , NOT | Combine or negate conditions |
String | LIKE , NOT LIKE | Pattern matching with wildcards |
Set | IN , NOT IN | Check for membership in a list/set |
Null Check | IS NULL , IS NOT NULL | Test for NULL values |
Bitwise (DBMS-specific) | & , ` | , ^, ~, <<, >>` |
🔹 Common Operators Explained
-- Arithmetic
SELECT price, price * 0.10 AS tax FROM products;
-- Comparison
SELECT * FROM employees WHERE salary >= 50000;
-- Logical
SELECT * FROM orders WHERE status = 'Shipped' AND total > 100;
-- String
SELECT * FROM customers WHERE name LIKE 'A%'; -- names starting with A
-- Set
SELECT * FROM products WHERE category IN ('Electronics', 'Books');
-- Null Check
SELECT * FROM employees WHERE manager_id IS NULL;
🧠 Quick Recap
Operator Type | Common Operators | Use Case |
---|---|---|
Arithmetic | + , - , * , / , % | Calculations |
Comparison | = , <> , < , > , <= , >= | Filtering by condition |
Logical | AND , OR , NOT | Combine multiple conditions |
Pattern Matching | LIKE | Partial text matching |
Set Membership | IN , NOT IN | Check against multiple values |
Null Testing | IS NULL , IS NOT NULL | Find NULL or NOT NULL values |
💡 Operators are the building blocks of your query logic—master them to write powerful SQL statements.