Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Inner join between two tables or timetables

`C = innerjoin(A,B)`

`C = innerjoin(A,B,Name,Value)`

```
[C,ia,ib]
= innerjoin(___)
```

creates
the table or timetable, `C`

= innerjoin(`A,B`

)`C`

, as the inner join between `A`

and `B`

by
matching up rows using all the variables with the same name as key variables. You
can perform inner joins only on certain combinations of tables and
timetables.

If

`A`

is a table, then`B`

must be a table.`innerjoin`

returns`C`

as a table.If

`A`

is a timetable, then`B`

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

returns`C`

as a timetable for either combination of inputs.

The inner join retains only the rows that match between `A`

and `B`

with
respect to the key variables. `C`

contains all nonkey
variables from `A`

and `B`

.

The row labels of `A`

and `B`

can
be key variables. Row labels are the row names of a table, or the
row times of a timetable.

performs
the inner-join operation with additional options specified by one
or more `C`

= innerjoin(`A,B`

,`Name,Value`

)`Name,Value`

pair arguments.

For example, you can specify the variables to use as key variables.

Row labels from the input tables `A`

and `B`

can
be keys, alone or in combination with other key variables. Row labels
are the row names of a table or the row times of a timetable. In general, `innerjoin`

copies
row labels from the input table `A`

to the output
table `C`

.

If

`A`

has no row labels, then`C`

has no row labels.If

`A`

has row labels, then`innerjoin`

copies row labels from`A`

to create row labels in`C`

.However, if both

`A`

and`B`

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

does not create row names in`C`

.

You cannot perform an inner join using the row labels of `A`

as
the left key and a variable of `B`

as the right key.
To perform the inner join, convert the row labels of `A`

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