Skip to content

Operators

JoshuaKennedy edited this page Oct 9, 2014 · 4 revisions
Contents
Overview
(+) Operator
(-) Operator
String/Character Operators
Comparison Operators

Overview

There are many operators in SQL, most of them are the same as other scripting/programming languages.

Arithmetic Operators

+ Operator

Performs addition on both sides of the operator.

Example

SELECT (1 + 1) FROM DUAL;

Output:

(1 + 1)
2

- Operator

Performs subtraction on both sides of the operator.

Example

SELECT (10 - 1) FROM DUAL;

Output:

(10 - 1)
9

String/Character Operators

|| Operator

Performs string concatenation on both sides of the operator. IIRC, both sides have to be strings, not sure though. 😕

Example

SELECT 'wow' || ' ' || 'such' || 'sql'
FROM DUAL;

Output:

'wow' || ' ' || 'such' || 'sql'
wow suchsql

Comparison Operators

!= Operator

Compares both sides of the operator and returns TRUE if they are not equal, FALSE if they are equal.

There are other inequality operators and they are: <>, and ^=

Example

SELECT (1 != 2), (69 <> 69)
FROM DUAL;

Outputs:

(1 != 2) (69 <> 69)
TRUE FALSE

TODO: Add other operators.

Clone this wiki locally