hsSqlExAnd: SQL Expression "AND"

View source: R/sql_expressions.R

hsSqlExAndR Documentation

SQL Expression “AND”

Description

Creates a boolean expression of the form
bFunc(x1) AND bFunc(x2) AND ... AND bFunc(xn). This function can be used to create SQL queries where many table fields have to be checked in the same way for some criterion (see example).

Usage

hsSqlExAnd(x, bFunc)

Arguments

x

vector of strings, e.g. representing table field names.

bFunc

name of a boolean function to be “applied” to each element of x.

See Also

hsSqlExOr

Examples

## Build SQL query finding records in table t in which all
## of the table fields f1 to f100 are NULL.
sql <- sprintf("SELECT * FROM t WHERE %s", 
               hsSqlExAnd(paste("f", 1:100, sep = ""), "isNull"))
  
## Show the SQL string
sql
  
## Output (middle part omitted):
# SELECT * FROM t WHERE (TRUE) AND isNull(f1) AND 
# isNull(f2) AND isNull(f3) AND ... AND isNull(f100)


KWB-R/kwb.db documentation built on Oct. 1, 2023, 4:10 a.m.