Qore SqlUtil Module Reference: SQL Join Operator Functions

Qore SqlUtil Module Reference 1.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
Functions
SQL Join Operator Functions

## Functions
hash | SqlUtil::join_inner (AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for standard inner joins with the given arguments More...
hash | SqlUtil::join_inner (Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for standard inner joins with the given arguments More...
hash | SqlUtil::join_inner (string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for standard inner joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::join_inner (string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for standard inner joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::join_left (AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for left outer joins with the given arguments More...
hash | SqlUtil::join_left (Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for left outer joins with the given arguments More...
hash | SqlUtil::join_left (string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for left outer joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::join_left (string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for left outer joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::join_right (AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for right outer joins with the given arguments More...
hash | SqlUtil::join_right (Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for right outer joins with the given arguments More...
hash | SqlUtil::join_right (string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for right outer joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::join_right (string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt)
| returns a hash for right outer joins with the given arguments for use when joining with a table other than the primary table More...
hash | SqlUtil::make_jop (string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt)
| returns a hash keyed with the table name assigned to a hash with `jop`, `table`, `jcols`, `cond`, `alias`, and `ta` keys More...

## Detailed Description

These are functions that can be used in the join argument in a select option hash:

- join_inner(): specifies an inner join
- join_left(): specifies a left outer join
- join_right(): specifies a right outer join

Note
  for join functions, explicit join columns do not need to be specified in the case that a foreign key in one table exists to the primary key of the other table; in this case this information is assumed for the join automatically

## Function Documentation

hash SqlUtil::join_inner | ( | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for standard inner joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid"))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_inner($table2)));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_inner | ( | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for standard inner joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid"))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_inner($table2)));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_inner | ( | string | ta,
|  | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for standard inner joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner("t2", $table3)));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_inner($table2)));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_inner | ( | string | ta,
|  | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for standard inner joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner("t2", $table3)));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_inner($table2)));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_left | ( | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for left outer joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", ("id": "altid"), ("tag", op_like("offset%")))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", NOTHING, ("tag", op_like("offset%")))));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_left | ( | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for left outer joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", ("id": "altid"), ("tag", op_like("offset%")))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", NOTHING, ("tag", op_like("offset%")))));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_left | ( | string | ta,
|  | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for left outer joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", ("id": "altid"), ("tag", op_like("offset%"))) + join_left("t2", $table3, "t3")));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", NOTHING, ("tag", op_like("offset%"))) + join_left("t2", $table3, "t3")));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_left | ( | string | ta,
|  | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for left outer joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", ("id": "altid"), ("tag", op_like("offset%"))) + join_left("t2", $table3, "t3")));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_left($table2, "t2", NOTHING, ("tag", op_like("offset%"))) + join_left("t2", $table3, "t3")));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_right | ( | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for right outer joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", ("id": "altid"), ("tag", op_like("offset%")))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", NOTHING, ("tag", op_like("offset%")))));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_right | ( | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for right outer joins with the given arguments

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", ("id": "altid"), ("tag", op_like("offset%")))));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", NOTHING, ("tag", op_like("offset%")))));

Parameters

  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_right | ( | string | ta,
|  | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for right outer joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", ("id": "altid"), ("tag", op_like("offset%"))) + join_right("t2", $table3, "t3")));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", NOTHING, ("tag", op_like("offset%"))) + join_right("t2", $table3, "t3")));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::join_right | ( | string | ta,
|  | Table | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *hash | opt
| ) |  |

returns a hash for right outer joins with the given arguments for use when joining with a table other than the primary table

Example With Explicit Join Columns:
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", ("id": "altid"), ("tag", op_like("offset%"))) + join_right("t2", $table3, "t3")));

Example With Implicit Join Columns:
  (using an automatically detected foreign key to primary key constraint)
  my *list $rows = $table.selectRows(("join": join_right($table2, "t2", NOTHING, ("tag", op_like("offset%"))) + join_right("t2", $table3, "t3")));

Parameters

  ta | the table name or alias of the other table to join with when not joining with the primary table
  table | the table to join with
  alias | the alias for table in the query
  jcols | the columns to use for the join, the keys will be columns in the source table and the values are columns in the table argument; if this argument is NOTHING, then if there is any foreign key in one table pointing to the primary key of the other table, then this information is automatically assumed as the join condition; a foreign constraint in the current table to the primary key in table will be used first if it exists
  cond | additional conditions for the join clause for the table argument; see Where Clauses for more information
  opt | optional join options (for example, to specify a partition for the join if supported)

Returns
  a join description hash corresponding to the arguments for use in the join argument of a select option hash

hash SqlUtil::make_jop | ( | string | jop,
|  | AbstractTable | table,
|  | *string | alias,
|  | *hash | jcols,
|  | *hash | cond,
|  | *string | ta,
|  | *hash | opt
| ) |  |

returns a hash keyed with the table name assigned to a hash with `jop`, `table`, `jcols`, `cond`, `alias`, and `ta` keys

Note
  this function is normally not used directly, but rather is called by the other SQL Join Operator Functions