Chapter 11. SQL Operators
Operators in SQL are defined as symbols and keywords that are used to specify an action to be performed on one or more expression called operands or arguments.
There are two general types of operators:
Unary operators: Applied to only one operand at the time; the typical format is <
operator
><operand
>.Binary operators: Applied to two operands at the time; they usually appear in the format <
operand
><operator
><operand
>.
Arithmetic and String Concatenation Operators
Arithmetic operators, just as the name implies, are used for arithmetic computations. The use of the arithmetic operators is very intuitive (assuming that one did not flunk elementary school), and they can be used in virtually every clause of the SQL statement. Table 11-1 provides the full list of arithmetic operators.
The string concatenation operator is a binary operator that glues two character strings together, and is, in a way, similar to the addition operator that adds two numbers. String concatenation operators are listed in Table 11-2.
Table 11.1. Arithmetic Operators
Operator | Description |
---|---|
| Addition; adds two numbers or — in the case of Microsoft SQL Server — also concatenates strings. With this exception, the usage is identical across all three databases. Only Microsoft SQL Server overloads the operator, using it both for concatenation and addition. Valid for all "big three" databases as well as for SQL:2003 syntax. |
| Subtraction; subtracts one numeric value from another. The usage is identical across ... |
Get SQL Bible, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.