SQL operators are special symbols or reserved words that evaluate to a value when placed between or in front of expressions. They are the building blocks of predicates, calculations, and control flow inside queries. Operators are grouped into categories:1. Arithmetic: + - * / % perform mathematical calculations on numeric data types.2. Comparison: = <> != ><>= <= IS IS NOT compare two values and return TRUE, FALSE, or UNKNOWN.3. Logical: AND OR NOT combine multiple boolean expressions into a single truth value.4. String/Concatenation: || (ANSI) or + (SQL Server) joins two strings.5. Bitwise: & | ^ ~ operate at the bit level (dialect specific).6. Set operators: UNION UNION ALL INTERSECT EXCEPT merge result sets while enforcing set logic.7. Other specialized operators include LIKE, BETWEEN, IN, ANY, ALL, SOME, and pattern-matching REGEXP/LRLIKE depending on dialect.Operator precedence determines evaluation order (e.g., * and / before + and -; NOT before AND before OR). Parentheses override precedence. NULLs propagate through arithmetic and comparison operators and yield UNKNOWN in boolean logic unless the operator explicitly treats NULL (e.g., IS NULL).
SQL FUNCTIONS, WHERE clause, CASE expression, ORDER BY, GROUP BY, SET OPERATORS, NULL handling
SQL-86 (first ANSI SQL standard)
UNION removes duplicate rows after combining result sets, whereas UNION ALL keeps duplicates and is therefore faster because it skips the distinct step.
The database evaluates expressions in a fixed order: parentheses first, arithmetic (*, /, %), arithmetic (+, -), comparison, NOT, AND, OR. Parentheses can override the default sequence.
You can, but arithmetic and comparison operators generally propagate NULL, returning NULL or UNKNOWN. Use COALESCE to replace NULLs or IS NULL for comparisons.
No. Bitwise operators (&, |, ^, ~) are supported in PostgreSQL, SQL Server, MySQL, and MariaDB, but not in standard SQLite or Oracle without extensions.