EasyTable: Single-File Embedded Database,
a BDE replacement for Delphi and C++Builder



Operators
Previous  Top  Next


Introduction

EasyTable SQL supports these operator categories:
·Arithmetic operators  
·Comparison operators  
·Logical operators  
·String concatenation operator  

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 the
BLOB, Memo, FmtMemo or Graphic 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.
EXISTS
TRUE if the subquery returns 1 or more rows.
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'))

SELECT * FROM orders 
WHERE CustNo IN 
 (SELECT DISTINCT CustNo FROM customer WHERE (Company LIKE 'S%') and (CustNo < 2500))
 ORDER BY CustNo

SELECT * FROM orders 
WHERE CustNo NOT IN 
 (SELECT DISTINCT CustNo FROM customer WHERE (Company LIKE 'S%') and (CustNo < 2500))
 ORDER BY CustNo

SELECT Count(*) as ROW_COUNT FROM jpeg
WHERE EXISTS 
 (SELECT * FROM jpeg WHERE (Name LIKE 'A%'))

SELECT Count(*) as ROW_COUNT FROM jpeg
WHERE NOT EXISTS 
 (SELECT * FROM jpeg WHERE (Name LIKE 'A%'))

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 



© AidAim Software EasyTable: Easytable Bde Alternative Single File Delphi Databas