SQL Expressions
Table of contents
Before you begin
identifier
FeatureBase identifiers (including object names such as databases, tables and columns) start with a lower-case alphabetic character and can include:
- lower-case alphabetic characters
- numbers 0-9
- dash
-
and underscore_
characters.
expr
Syntax | Example | Result |
---|---|---|
expr [NOT] LIKE expr | SELECT * FROM products WHERE prodlist LIKE 'pen'; | ballpen , pencil , playpen |
expr IS [NOT] null | SELECT * FROM services WHERE price IS null; | free delivery on orders over $50 |
expr [NOT] between expr AND expr | SELECT * from Products WHERE Price BETWEEN 10 AND 20; | fountain pen , notepad , rubber ball |
expr [NOT] IN ([SELECT_stmnt | expr,...]) | Select * from Products where product_ID NOT IN (SELECT product_ID from Sales where product_name LIKE ear) | gold-plated earplugs |
Literals
Literals are explicitly specified fixed values that conform to a specific data type:
String literal | BNF diagram | Further information |
---|---|---|
date | TIMESTAMP() data type | |
decimal | DECIMAL() data type | |
set | IDSET data type STRINGSET data type | |
string | STRING data type | |
tuple | Tuple literals are a collection of data types. |
[unary_op] expr
expr binary_op expr
function_call
CAST expr AS type_name
Syntax | Example | Result |
---|---|---|
CAST expr AS type_name | SELECT CAST (25.65 AS int); | 25 |
paren_select_stmt
A SQL Statement nested within another SQL statement.