R/sql_join.R
sqlFullLeftJoin.Rd
Merge SQL Queries to One Query That Performs a Full Left Join
sqlFullLeftJoin(sqls, key)
sqls | list of SQL queries each of which is expected to contain an
attribute |
---|---|
key | name of the primary key field, being selected in each SQL query
contained in |
vector of character of length one representing the result of "left
join"-ing all sub-queries given in sqls
sql <- sqlFullLeftJoin(key = "id", list( structure("SELECT id, field_1 from table_1", alias = "t1"), structure("SELECT id, field_2, field_3 from table_2", alias = "t2"), structure("SELECT id, field_4 from table_3", alias = "t3") )) cat(sql)#> ( SELECT id, field_1 from table_1 AS t1 #> LEFT JOIN SELECT id, field_2, field_3 from table_2 AS t2 #> ON ( t1.id = t2.id ) ) #> LEFT JOIN SELECT id, field_4 from table_3 AS t3 #> ON ( t1.id = t3.id )