Add Join (Data Management)

joining a table view to a layer (or a table view to a table view) based on a common field.

The records in the input layer or table view are matched to the record in the join table view based on the join field and the Input Field when the values are equal. The join is temporary as is the layer and will not persist from one session to the next unless the document is saved.


Illustration

Add Join

Usage tips

Syntax

AddJoin_management (in_layer_or_view, in_field, join_table, join_field, join_type)
Parameter Explanation Datatype
Layer Name (Required)

The layer or table view to which the join table will be joined.

Table View | Raster Layer
Input Join Field (Required)

The field in the input layer or table view on which the join will be based.

Field
Join Features (Required)

The table or table view to be joined to the input layer or table view.

Table View | Raster Layer
Output Join Field (Required)

The field in the join table that contains the values on which the join will be based.

Field
Outer Join (Optional)

Specifies what will be done with records in the input that match a record in the join table.

  • KEEP_ALL—All records in the input layer or table view will be included in the output; also known as an outer join. This is the default.
  • KEEP_COMMON—Only those records in the input that match to a row in the join table will be present in the result; also known as an inner join.

Boolean
Data types for geoprocessing tool parameters

Script Example

# ExportCADWithJoin.py
# Description: To Export to an AutoCAD file, with each layer created from the Name field in the feature class.
#              AddJoin is used to join the attribute table with the feature class
# Requirements: Python and the Python win32all extension
# Author: ESRI
# Data 1/1/2004

# Create the Geoprocessor object
import arcgisscripting
gp = arcgisscripting.create()

# Local variables...
ImportCAD_mdb = "C:/Test_data/B_0074_ImportCAD.mdb"
Line_fc = "C:/Test_data/B_0074_ImportCAD.mdb/CADStaging/Line"
Entity = "C:/Test_data/B_0074_ImportCAD.mdb/Entity"
property = "C:/Test_data/B_0074_ImportCAD.mdb/property"

try:
    # Process: Make Layer...
    gp.MakeFeatureLayer_management(Line_fc, "lines_lyr", "", "", "EntID EntID VISIBLE;Shape_Length Shape_Length VISIBLE")
    # Process: Add Join...
    gp.AddJoin_management("lines_lyr", "EntID", Entity, "EntID", "KEEP_ALL")

    # Process: Select Layer By Attribute...
    gp.SelectLayerByAttribute_management("lines_lyr", "NEW_SELECTION", ""Entity.Layer" = 'B-PROPLINE'")

    # Process: Feature To Polygon...
    gp.FeatureToPolygon_management("lines_lyr", property, "", "ATTRIBUTES", "")

except:
    # If an error occurred while running a tool print the messages
    print "An error occured"
    print gp.GetMessages()

See Also

  • Create relationship class (Data Management)
  • Remove Join (Data Management)
  • Join Field (Data Management)
  • Table to Relationship Class (Data Management)