Operators


doogiePIM SQL supports these operator categories:


Arithmetic Operators

Arithmetic operators perform mathematical operations on two expressions of any of the data types of the numeric data type category.


Operator                Meaning

+ (Add)                Addition

- (Subtract)                Subtraction

* (Multiply)                Multiplication

/ (Divide)                Division


Example:

SELECT (Price * Quantity) AS Total FROM Order


Comparison Operators

Comparison operators test whether or not two expressions are the same. Comparison operators can be used on all expressions except expressions of BLOB data types.


Operator

Meaning

=

Equal To

>

Greater Than

<

Less Than

>=

Greater Than or Equal To

<=

Less Than or Equal To

<>

Not Equal To


The result of a comparison operator has the Boolean data type, which has three values: TRUE, FALSE, and UNKNOWN. Expressions that return a Boolean data type are known as Boolean expressions.


If an operator that has one or two NULL expressions, returns UNKNOWN.

Expressions with Boolean data types are used in the WHERE clause to filter the rows that qualify for the search conditions


Example:


SELECT * FROM Orders WHERE (TaxRate > 0)

   

Logical Operators


Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a Boolean data type with a value of TRUE or FALSE.


Operator        Meaning

AND                TRUE if both Boolean expressions are TRUE.

BETWEEN        TRUE if the operand is within a range.

IN                TRUE if the operand is equal to one of a list of expressions.

LIKE                TRUE if the operand matches a pattern.

NOT                Reverses the value of any other Boolean operator.

OR                TRUE if either Boolean expression is TRUE.

IS NULL        TRUE if Boolean expression is UNKNOWN

Examples:


SELECT  *  FROM Customer  WHERE (Company LIKE '%Club%')


SELECT  *  FROM Orders  WHERE (ShipToCity IS NOT NULL)


SELECT  *  FROM Orders WHERE (TaxRate BETWEEN 0 and 5) AND (AmountPaid > 1)


SELECT  *  FROM Orders WHERE (ShipVIA IN ('UPS', 'DHL'))


String Concatenation Operator


The string concatenation operator allows string concatenation with the addition sign (+) or concatenation sign (||), which is also known as the string concatenation operator.


Example:


SELECT  (FirstName + ' ' + LastName)  AS  Name  FROM Customers 


Related Topics

Naming Conventions

Operators

String Functions

Date Functions