-
Notifications
You must be signed in to change notification settings - Fork 0
Operators
Contents |
---|
Overview |
(+) Operator |
(-) Operator |
String/Character Operators |
Comparison Operators |
There are many operators in SQL, most of them are the same as other scripting/programming languages.
Performs addition on both sides of the operator.
SELECT (1 + 1) FROM DUAL;
Output:
(1 + 1) |
---|
2 |
Performs subtraction on both sides of the operator.
SELECT (10 - 1) FROM DUAL;
Output:
(10 - 1) |
---|
9 |
Performs string concatenation on both sides of the operator. IIRC, both sides have to be strings, not sure though. 😕
SELECT 'wow' || ' ' || 'such' || 'sql'
FROM DUAL;
Output:
'wow' || ' ' || 'such' || 'sql' |
---|
wow suchsql |
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 ^=
SELECT (1 != 2), (69 <> 69)
FROM DUAL;
Outputs:
(1 != 2) | (69 <> 69) |
---|---|
TRUE | FALSE |
TODO: Add other operators.
Code examples contained herein are created by Chad Jensen (@cbjjensen) and/or Josh Kennedy (@JoshuaKennedy) and are placed in the public domain.
THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE CODE.