# outerjoin

Outer join between two tables or timetables

## Syntax

## Description

creates the table or timetable, `T`

= outerjoin(`Tleft`

,`Tright`

)`T`

, as the *outer
join* of `Tleft`

and `Tright`

using
key variables. An outer
join combines table rows where the key variables have matching values, but it also
includes rows where the key variables from one input table have no matches in the
other input table. For example, if `Tleft`

has variables named
`Key1`

and `Var1`

, and
`Tright`

has variables `Key1`

and
`Var2`

, then `T=outerjoin(Tleft,Tright)`

uses
`Key1`

as a key variable.

By default, the key variables are:

Variables that have the same names in

`Tleft`

and`Tright`

, if both inputs are tables, or if`Tleft`

is a timetable and`Tright`

is a table.Vectors of row times, if both

`Tleft`

and`Tright`

are timetables.

The matching values of the key variables in the left and right tables do not have to be in the same order. Outer joins can perform one-to-many and many-to-one matches between the key variables of the two tables. That is, a value that occurs once in a key variable of the left table can have multiple matches in the right table. Similarly, a value that occurs once in a key variable of the right table can have multiple matches in the left table.

You can perform outer joins only on certain combinations of tables and timetables.

If

`Tleft`

is a table, then`Tright`

must be a table.`outerjoin`

returns`T`

as a table.If

`Tleft`

is a timetable, then`Tright`

can be either a table or a timetable.`outerjoin`

returns`T`

as a timetable for either combination of inputs.

performs the outer-join operation with additional options specified by one or more
`T`

= outerjoin(`Tleft`

,`Tright`

,`Name,Value`

)`Name,Value`

pair arguments.

## Examples

## Input Arguments

## Output Arguments

## More About

## Algorithms

The vector of row labels from an input table or timetable can be used as a key variable, alone or in combination with other key variables. Row labels are the row names of a table or the row times of a timetable. To use this vector as a key, specify it as

`'Row'`

(for the row names of a table), as the name of a timetable vector of row times, or as the value of

, where.Properties.DimensionNames{1}`T`

is the table or timetable.`T`

In general,

`outerjoin`

copies row labels from the input table`Tleft`

to the output table`T`

.If

`Tleft`

has no row labels, then`T`

has no row labels.If

`Tleft`

has row labels, then`outerjoin`

copies row labels from`Tleft`

to create row labels in`T`

.If you specify row labels from both

`Tleft`

and`Tright`

as a key pair, then`outerjoin`

merges row labels from`Tright`

into row labels of`T`

where needed.If you specify row labels of

`Tleft`

as a key, but do not specify row labels of`Tright`

as the matching key, then`outerjoin`

creates default row labels in`T`

where needed. Typically, default row labels are`NaN`

s or missing valuesIf both

`Tleft`

and`Tright`

are tables, but you do not specify either input’s row names as a key, then`outerjoin`

does not create row names in`T`

.If both

`Tleft`

and`Tright`

are timetables, but you do not specify either input’s row times as a key, then`outerjoin`

copies row times from`Tleft`

to`T`

. It also fills in`NaN`

s or`NaT`

s as row times where needed.

You cannot perform an outer join using the row labels of

`Tleft`

as the left key and a variable of`Tright`

as the right key. To perform the outer join, convert the row labels of`Tleft`

to a table variable and use the new table variable as a key.

## Extended Capabilities

## Version History

**Introduced in R2013b**

## See Also

`join`

| `innerjoin`

| Join
Tables