JOIN: Joins of all flavors

Description Usage Arguments Examples

View source: R/sqrrl.R

Description

Produces a JOIN snippet

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
JOIN(left_ref, right_tbls, on, cond = NULL, prefer_using = TRUE,
  type = "")

LEFT_JOIN(left_ref, right_tbls, on, cond = NULL, prefer_using = TRUE)

RIGHT_JOIN(left_ref, right_tbls, on, cond = NULL, prefer_using = TRUE)

INNER_JOIN(left_ref, right_tbls, on, cond = NULL, prefer_using = TRUE)

OUTER_JOIN(left_ref, right_tbls, on, cond = NULL, prefer_using = TRUE)

Arguments

left_ref

Reference for left table (name or alias)

right_tbls

Character vector of right-hand side table names, names will be used as table aliases

on

Vector or list of conditions. If a vector, all conditions are applied to all tables. If a list, conditions are matched by order to the RHS table names. Names of entries in any vectors are used as LHS column names.

cond

Optional additional conditions.

prefer_using

Should USING clause be used instead of ON where possible?

type

Join type string (can be lowercase): LEFT, RIGHT, INNER, CROSS, NATURAL LEFT, RIGHT OUTER.

Examples

1
2
3
4
5
6
7
JOIN('left_tbl', 'right_tbl', 'id')
LEFT_JOIN('l', c('r' = 'right_tbl'), 'id')
LEFT_JOIN('l', c('r' = 'right_tbl'), 'id', prefer_using = FALSE)
RIGHT_JOIN('left_tbl', 'right_tbl', c('left.col1' = 'right.col1', 'id2'))
INNER_JOIN('left_tbl', c('right_1', 'right_2'), 'id_col')
OUTER_JOIN('l', c(r1 = 'right_1', r2 = 'right_2'), list('col1', 'col2'))
JOIN(type = "natural right", 'l', c(r1 = 'right_1', r2 = 'right_2'), list(c(left.col1 = 'col1', c(left.col2 = 'col2'))))

gadenbuie/sqrrrl documentation built on May 24, 2019, 4:04 a.m.