Column Expressions
Column expression can be one of the following (and these can be
combined with each other to get different expressions) :
- Column : Column can be qualified or unqualified.
(Qualified column name is the one in which the column name is prefixed
by table name separted by a dot)
- TableWildCard : A TableWildCard is of the form TableName.*
. This indicates, all the columns of the specified table.
- Literals: Refer Literals for detailed
description.
- Prepared statement Variables :
- Boolean Values : Boolean value is either TRUE or FALSE.
- Unary expressions: + or - prefixed to any column
expression, forms a Unary expression.
- Case Expression : Case expressions are used to switch
between the results, depending on the incoming values or depending on
some conditions. There are two types of case expressions as follows:
- Simple Case Expression:
- Searched Case Expression:
- IfNull function : IfNull function operates on two
column expressions. If the first expression doesn't evaluate to NULL,
then the result of the first expression is returned as the result of
IFNULL function. Otherwise, result of the second expression is returned
as the result of IFNULL function.
Syntax: IFNULL ( ColumnExpression "," ColumnExpression
)
Eg: IFNULL ( X/2, 5 )
- Cast function : Cast function is used to convert the
data type of one expression to another data type, provided the
conversion between the two data types are allowed.
Sytax: CAST ( ColumnExpression AS DataType
)
Eg: CAST ( X/2 AS INT )
Refer: DataTypes
- Aggregate functions : Aggregate functions are used to
perform aggregate(set) function on the values of a particular column
expression. Aggregate functions supported are COUNT, MAX, MIN, SUM,
AVG.
Syntax: AggrFunctionName ( ColumnExpression )
Eg: COUNT(*) , SUM(ID) , MAX(ID+10)
Comparison Operators
Comparison operators supported are:
- = , <>
- > , >=
- < , <=
- LIKE