QBSearchedCaseExpression
Overview
The QBSearchedCaseExpression
class provides functionality for constructing SQL case expressions with dynamic branching logic. It supports the definition of complex conditional logic directly within queries, enabling nuanced data manipulation and evaluation.
This class allows for a wide range of operations on columns, including mathematical functions (e.g., abs
, ceil
, sqrt
), string manipulations (e.g., upper
, trim
, concat
), and date extractions (e.g., year
, month
, day
). Additionally, it facilitates comparisons, aggregate operations (e.g., sum
, avg
), and casting of column types. These features make it a versatile tool for building expressive and dynamic queries.
For further details, refer to the QBSelect documentation.
Properties Summarized
Methods Summarized
The flags are a bit pattern consisting of 1 or more of the following bits: - JSColumn.
Properties Detailed
abs
Create abs(column) expression
Type QBColumn a QBFunction representing the absolute value function.
Sample
asc
Create an ascending sort expression
Type QBSort a QBSort representing an ascending sort order.
Sample
avg
Create an aggregate average expression.
Type QBColumn a QBAggregate representing the average aggregate function.
Sample
bit_length
Create bit_length(column) expression
Type QBColumn a QBFunction representing the bit length function.
Sample
ceil
Create ceil(column) expression
Type QBColumn a QBFunction representing the ceil function.
Sample
count
Create an aggregate count expression.
Type QBColumn a QBAggregate representing the count aggregate function.
Sample
day
Extract day from date
Type QBColumn a QBFunction representing the extraction of the day from a date.
Sample
desc
Create an descending sort expression
Type QBSort a QBSort representing a descending sort order.
Sample
floor
Create floor(column) expression
Type QBColumn a QBFunction representing the floor function.
Sample
hour
Extract hour from date
Type QBColumn a QBFunction representing the extraction of the hour from a date.
Sample
isNull
Compare column with null.
Type QBCondition a QBCondition representing the "is null" comparison.
Sample
len
Create length(column) expression
Type QBColumn a QBFunction representing the length function.
Sample
lower
Create lower(column) expression
Type QBColumn a QBFunction representing the lower case transformation.
Sample
max
Create an aggregate max expression.
Type QBColumn a QBAggregate representing the maximum aggregate function.
Sample
min
Create an aggregate min expression.
Type QBColumn a QBAggregate representing the minimum aggregate function.
Sample
minute
Extract minute from date
Type QBColumn a QBFunction representing the extraction of the minute from a date.
Sample
month
Extract month from date
Type QBColumn a QBFunction representing the extraction of the month from a date.
Sample
not
Create a negated condition.
Type QBColumn a QBColumn representing the negated condition.
Sample
parent
Get query builder parent table clause, this may be a query or a join clause.
Type QBTableClause
Sample
root
Get query builder parent.
Type QBSelect
Sample
round
Create round(column) expression
Type QBColumn a QBFunction representing the round function.
Sample
second
Extract second from date
Type QBColumn a QBFunction representing the extraction of the second from a date.
Sample
sqrt
Create sqrt(column) expression
Type QBColumn a QBFunction representing the square root function.
Sample
sum
Create an aggregate sum expression.
Type QBColumn a QBAggregate representing the sum aggregate function.
Sample
trim
Create trim(column) expression
Type QBColumn a QBFunction representing the trim function.
Sample
upper
Create upper(column) expression
Type QBColumn a QBFunction representing the upper case transformation.
Sample
year
Extract year from date
Type QBColumn a QBFunction representing the extraction of the year from a date.
Sample
Methods Detailed
between(value1, value2)
Compare column to a range of 2 values or other columns.
Parameters
Returns: QBCondition a QBCondition representing the "between" comparison for the two values.
Sample
cast(type)
Create cast(column, type) expression
Parameters
String type string type, see QUERY_COLUMN_TYPES
Returns: QBColumn a QBFunction representing the cast function with the specified type.
Sample
concat(arg)
Concatename with value
Parameters
Object arg valeu to concatenate with
Returns: QBColumn a QBFunction representing the concatenation operation.
Sample
divide(arg)
Divide by value
Parameters
Object arg nr to divide by
Returns: QBColumn a QBFunction representing the division operation.
Sample
eq(value)
Compare column with a value or another column. Operator: equals
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "equals" comparison.
Sample
ge(value)
Compare column with a value or another column. Operator: greaterThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than or equal to" comparison.
Sample
getFlags()
The flags are a bit pattern consisting of 1 or more of the following bits: - JSColumn.UUID_COLUMN - JSColumn.EXCLUDED_COLUMN - JSColumn.TENANT_COLUMN
Returns: Number an integer representing the flags of the column.
getTypeAsString()
Column type as a string
Returns: String a string representing the column type.
gt(value)
Compare column with a value or another column. Operator: greaterThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than" comparison.
Sample
isin(query)
Compare column with subquery result.
Parameters
QBPart query subquery
Returns: QBCondition a QBCondition representing the "in" comparison with a subquery.
Sample
isin(values)
Compare column with values.
Parameters
Array values array of values
Returns: QBCondition a QBCondition representing the "in" comparison with a list of values.
Sample
isin(customQuery, args)
Compare column with custom query result.
Parameters
Returns: QBCondition a QBCondition representing the "in" comparison with a custom query and arguments.
Sample
le(value)
Compare column with a value or another column. Operator: lessThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than or equal to" comparison.
Sample
like(pattern)
Compare column with a value or another column. Operator: like
Parameters
Object pattern the string value of the pattern
Returns: QBCondition a QBCondition representing the "like" comparison with a pattern.
Sample
like(pattern, escape)
Compare column with a value or another column. Operator: like, with escape character
Parameters
Returns: QBCondition a QBCondition representing the "like" comparison with a pattern and an escape character.
Sample
locate(arg)
Create locate(arg) expression
Parameters
Object arg string to locate
Returns: QBColumn a QBFunction representing the locate function for the specified string.
Sample
locate(arg, start)
Create locate(arg, start) expression
Parameters
Returns: QBColumn a QBFunction representing the locate function starting from the specified position.
Sample
lt(value)
Compare column with a value or another column. Operator: lessThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than" comparison.
Sample
minus(arg)
Subtract value
Parameters
Object arg nr to subtract
Returns: QBColumn a QBFunction representing the subtraction operation.
Sample
mod(arg)
Create mod(arg) expression
Parameters
Object arg mod arg
Returns: QBColumn a QBFunction representing the modulo operation.
Sample
multiply(arg)
Multiply with value
Parameters
Object arg nr to multiply with
Returns: QBColumn a QBFunction representing the multiplication operation.
Sample
nullif(arg)
Create nullif(arg) expression
Parameters
Object arg object to compare
Returns: QBColumn a QBFunction representing the nullif function.
Sample
plus(arg)
Add up value
Parameters
Object arg nr to add
Returns: QBColumn a QBFunction representing the addition operation.
Sample
substring(pos)
Create substring(pos) expression
Parameters
Number pos ;
Returns: QBColumn a QBFunction representing the substring function starting from the specified position.
Sample
substring(pos, len)
Create substring(pos, len) expression
Parameters
Returns: QBColumn a QBFunction representing the substring function with the specified position and length.
Sample
Last updated
Was this helpful?