Generate an SQL snippet for SELECT or SELECT DISTINCT

SELECT(..., .distinct = FALSE)

SELECT_(table_cols = NULL, .distinct = FALSE)




Columns to select. Single arguments are assumed to be column names. Single named arguments are renamed columns. Named arguments with a vector of length greater than 1 or a vector with named entries are assumed to be table names; entry names are column aliases.


If true, uses SELECT DISTINCT as keyword


Named list of tables and columns


  • SELECT_: Standard eval version of SELECT

  • SELECT_DISTINCT: Alias for SELECT(..., .distinct = TRUE)


#> [1] "SELECT a, b, c"
SELECT(letters[1:3], 't2' = letters[4:6])
#> [1] "SELECT a, b, c, t2.d, t2.e, t2.f"
SELECT(a = 'apple', b = 'banana', c = 'cherry')
#> [1] "SELECT apple as a, banana as b, cherry as c"
SELECT('t1' = c(a = 'apple', b = 'banana'), c = 'cherry')
#> [1] "SELECT as a, t1.banana as b, cherry as c"
SELECT('t1' = c(a = 'apple', b = 'banana'), c = 'cherry', 't2' = c(d = 'dragon_fruit'))
#> [1] "SELECT as a, t1.banana as b, cherry as c, t2.dragon_fruit as d"
SELECT_(list('t1' = c('a', z = 'b'), 't2' = 'c'))
#> [1] "SELECT t1.a, t1.b as z, t2.c"