Skip to content

Chained CRUD - Condition Methods

All condition methods return the cDataBase object, allowing free stacking and combination. For architecture details, see Chained CRUD Overview.


Where - WHERE Condition

Sets WHERE AND condition, supports ? placeholder + automatic parameter escaping.

Syntax

vb
Function Where(ByVal Condition As String, ParamArray Params() As Variant) As cDataBase

Example

vb
' Simple condition
db.Table("users").Where("age > 18").RowRead

' Placeholder parameters (auto-escape single quotes)
db.Table("users").Where("name=?", "Zhang San").RowRead

' Multiple parameters
db.Table("users").Where("name=? AND age>?", "Zhang San", 18).RowRead

OrWhere - OR Condition

Adds OR condition, connected with OR to the AND conditions from Where.

Syntax

vb
Function OrWhere(ByVal Condition As String, ParamArray Params() As Variant) As cDataBase

Example

vb
' AND + OR combination
' Generated SQL: WHERE age > 18 OR (status = 'VIP')
db.Table("users").Where("age>?", 18).OrWhere("status=?", "VIP").RowRead

' Multiple OrWhere
' Generated SQL: WHERE age > 18 OR (role='admin' OR role='super')
db.Table("users").Where("age>?", 18).OrWhere("role='admin'").OrWhere("role='super'").RowRead

WhereIn - IN Condition

Field value is in the specified list. Supports comma-separated string or multiple parameter forms.

Syntax

vb
Function WhereIn(ByVal FieldName As String, ParamArray Values() As Variant) As cDataBase

Example

vb
' Comma-separated string form
db.Table("users").WhereIn("status", "active,pending,closed").RowRead

' Multiple parameter form
db.Table("users").WhereIn("id", 1, 2, 3, 5, 8).RowRead

' Combined with other conditions
db.Table("users").Where("age>?", 18).WhereIn("dept", "IT,HR").RowRead

WhereNotIn - NOT IN Condition

Field value is not in the specified list.

Syntax

vb
Function WhereNotIn(ByVal FieldName As String, ParamArray Values() As Variant) As cDataBase

Example

vb
' Exclude specified roles
db.Table("users").WhereNotIn("role", "admin,root,superadmin").RowRead

WhereBetween - BETWEEN Condition

Field value is between two values.

Syntax

vb
Function WhereBetween(ByVal FieldName As String, ByVal Value1 As Variant, ByVal Value2 As Variant) As cDataBase

Example

vb
' Age range query
db.Table("users").WhereBetween("age", 18, 30).RowRead

' Date range query
db.Table("orders").WhereBetween("created_at", "2025-01-01", "2025-12-31").RowRead

' Combined conditions
db.Table("users").Where("dept=?", "IT").WhereBetween("salary", 5000, 15000).RowRead

WhereNotBetween - NOT BETWEEN Condition

vb
db.Table("users").WhereNotBetween("age", 18, 30).RowRead

WhereLike - LIKE Fuzzy Match

Syntax

vb
Function WhereLike(ByVal FieldName As String, ByVal Pattern As String) As cDataBase

Example

vb
' Contains match
db.Table("users").WhereLike("name", "%Zhang%").RowRead

' Prefix match
db.Table("users").WhereLike("email", "admin%").RowRead

' Combined with other conditions
db.Table("users").Where("dept=?", "IT").WhereLike("name", "%Zhang%").RowRead

WhereNotLike - NOT LIKE

vb
db.Table("users").WhereNotLike("name", "%test%").RowRead

WhereNull - IS NULL Condition

Syntax

vb
Function WhereNull(ByVal FieldName As String) As cDataBase

Example

vb
' Query records not deleted
db.Table("users").WhereNull("deleted_at").RowRead

' Query users without email set
db.Table("users").WhereNull("email").RowRead

WhereNotNull - IS NOT NULL Condition

vb
' Query users with verified email
db.Table("users").WhereNotNull("email_verified_at").RowRead

Last Updated: 2026-06-26

VB6 and LOGO copyright of Microsoft Corporation