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 cDataBaseExample
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).RowReadOrWhere - 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 cDataBaseExample
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'").RowReadWhereIn - 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 cDataBaseExample
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").RowReadWhereNotIn - NOT IN Condition
Field value is not in the specified list.
Syntax
vb
Function WhereNotIn(ByVal FieldName As String, ParamArray Values() As Variant) As cDataBaseExample
vb
' Exclude specified roles
db.Table("users").WhereNotIn("role", "admin,root,superadmin").RowReadWhereBetween - 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 cDataBaseExample
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).RowReadWhereNotBetween - NOT BETWEEN Condition
vb
db.Table("users").WhereNotBetween("age", 18, 30).RowReadWhereLike - LIKE Fuzzy Match
Syntax
vb
Function WhereLike(ByVal FieldName As String, ByVal Pattern As String) As cDataBaseExample
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%").RowReadWhereNotLike - NOT LIKE
vb
db.Table("users").WhereNotLike("name", "%test%").RowReadWhereNull - IS NULL Condition
Syntax
vb
Function WhereNull(ByVal FieldName As String) As cDataBaseExample
vb
' Query records not deleted
db.Table("users").WhereNull("deleted_at").RowRead
' Query users without email set
db.Table("users").WhereNull("email").RowReadWhereNotNull - IS NOT NULL Condition
vb
' Query users with verified email
db.Table("users").WhereNotNull("email_verified_at").RowReadLast Updated: 2026-06-26