JoinAcross

JoinAcross[{a1,a2,},{b1,b2,},key]
gives a list of associations obtained by joining those pairs of associations and in which the values associated with key are the same.

JoinAcross[{a1,a2,},{b1,b2,},{key1,key2,}]
joins pairs of associations only when the values associated with all keys are the same.

JoinAcross[{a1,a2,},{b1,b2,},keysakeysb]
joins pairs of associations , in which the values associated with in the are the same as those associated with in the .

JoinAcross[{a1,a2,},{b1,b2,},{keysa1keysb1,}]
joins pairs of associations in which pairs of corresponding values agree.

JoinAcross[alist,blist,spec,"jspec"]
uses jspec to determine when to allow associations that contain missing elements to be generated.

DetailsDetails

  • JoinAcross[{a1,a2,},{b1,b2,},spec] effectively implements the analog of SQL JOIN, joining two tables with rows and across columns specified by spec.
  • Key specifications in JoinAcross must be wrapped in Key unless they are strings.
  • JoinAcross effectively generates a filtered version of Flatten[Outer[Join,alist,blist]].
  • By default, JoinAcross does an "inner join" in the SQL sense.
  • The following forms for specify different behavior for pairs of associations , :
  • "Inner"keep only those , for which values match (default)
    "Left"allow for which there is no matching
    "Right"allow for which there is no matching
    "Outer"allow both unmatched and
  • When a corresponding value is absent, Missing["Unmatched"] is used in its place.

ExamplesExamplesopen allclose all

Basic Examples  (8)Basic Examples  (8)

Join two associations:

In[1]:=
Click for copyable input
Out[1]=

Join pairs of associations with the same value for the specified key:

In[1]:=
Click for copyable input
Out[1]=

Join using several keys:

In[1]:=
Click for copyable input
Out[1]=

Join by different keys on the left and on the right:

In[1]:=
Click for copyable input
Out[1]=

With join (default), combine only the matched associations:

In[1]:=
Click for copyable input
Out[1]=

With join, include unmatched entries from the left list:

In[1]:=
Click for copyable input
Out[1]=

With join, unmatched entries from the right list are included:

In[1]:=
Click for copyable input
Out[1]=

With join, include all unmatched entries:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)