NOT

abstract fun NOT(expression: Clause.Expression): Clause.Expression

Creates a logical NOT expression.

This function negates the result of a given expression. It is commonly used to reverse a condition in a WHERE or HAVING clause.

Example

// Generates: NOT ("age" < 18)
NOT(Employees.age LT 18)

// Generates: NOT ("country" = 'USA' AND "status" = 'active')
NOT((Employees.country EQ "USA") AND (Employees.status EQ "active"))

Return

A new Expression representing the negated condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

expression

The Expression to be negated.


abstract fun NOT(value: KQLiteColumn<*>): Clause.Expression


fun NOT(selectStatement: SelectStatement<*>): Clause.Expression

Creates a logical NOT expression for a subquery.

This function negates the result of a subquery. It's often used with EXISTS or other subquery-based conditions, although its direct use (NOT (subquery)) is less common in standard SQL than NOT EXISTS or NOT IN. The behavior may vary across SQL dialects. For checking non-existence, NOT_EXISTS is generally preferred.

Example

// Generates: NOT (SELECT "order_time" FROM "Orders" WHERE "customer_id" = "Customers"."id")
// This is functionally similar to NOT_EXISTS in many cases.
NOT(
Orders.select(Orders.orderTime).where { Orders.customerId EQ Customers.id }
)

Return

An Expression representing the NOT (subquery) condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

selectStatement

The subquery whose result will be negated.

See also