Description Usage Arguments Details Value Examples
Returns SQL IN statement as a string. Supports multi-variable value matching with tuples.
1 | build_sql_in(var_names, values)
|
var_names |
A character vector specifying the names of the database
columns to which the condition applies. If |
values |
A vector or data frame containing values to match on. Factors will be converted to strings. Rows of a data frame are treated as tuples. |
Concatenates values in a vector and returns them in a SQL conditional format. This is necessary since Friday Institute researchers are given read-only access to the database. Otherwise, you could use dplyr join commands with copy=TRUE, which would create a temporary table in the database, so the database can handle the calculations. If this breaks, you can always pull the entire table and do subsetting locally, but that's obviously expensive.
A string of format "name IN (value1, value2, ...)"
for vector
inputs and "(name1, name2) IN ((name1value1, name2value1), ...)"
for
data frames.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
courseids <- c(1, 2, 3)
build_sql_in("courseid", courseids)
# tuple
tuple <- tribble(
~courseid, ~userid,
1, 1,
1, 2,
2, 3,
2, 4
)
build_sql_in(c("courseid", "userid"), tuple)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.