ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Add Join

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Joins a layer to another layer or table (where layer is a feature layer, table view, or raster layer with a raster attribute table) based on a common field.

The records in the Join Table are matched to the records in the input Layer Name. A match is made when the input join field and output join field values are equal. This join is temporary.

Illustration

Add Join

Usage

  • The input must be a feature layer, a table view, or a raster layer that has an attribute table; it cannot be a feature class or table.

  • Records from the Join Table can be matched to more than one record in the input layer or table view. For more information on one-to-one, many-to-one, one-to-many, and many-to-many joins, see About joining and relating tables.

  • When joining tables, the default option is to keep all records. If a record in the target table doesn't have a match in the join table, that record is given null values for all the fields being appended into the target table from the join table.

    Example of keeping all records with a join

    With the keep only matching records option, if a record in the target table doesn't have a match in the join table, that record is removed from the resultant target table. If the target table is the attribute table of a layer, features that don't have data joined to them are not shown on the map.

    Example of keeping only matching records with a join

  • The Join Table can be any of the following types of tables: a geodatabase table, a dBASE file, an INFO table, or an OLE DB table.

  • The input layer or table view must have an ObjectID field. The Join Table is not required to contain an ObjectID field.

  • Field properties, such as aliases, visibility, and number formatting, are maintained when a join is added or removed.

  • If a join with the same table name already exists—for example, if the layer A is joined to a table B—running the tool again to join table B will result in a warning that the join already exists.

  • The join lasts only for the duration of the session. To persist the join for use in another session, save the layer to a layer file using the Save Layer To File tool. This only applies to layers; table views cannot be saved in this manner.

  • In the resulting layer or table view, the fields from the input layer or table view will be prefixed with the input's name and a period (.), and all fields from the join table will be prefixed with the join table name plus a period as the default.

    • For example, joining landuse, which has fields A and B to lookup_tab, which has fields C and D, will result in a layer or table view with the following fields: landuse.A, landuse.B, lookup_tab.C, and lookup_tab.D.
    • For coverage feature classes and INFO tables, the table and field name separator is a colon (:) instead of a period.

  • To make a permanent join, consider using the Join Field tool. Another way to make the join permanent is to save the joined feature layer to a new feature class or the joined table view to a new table. When saving results to a new feature class or table, you can use the Qualified Field Names environment to control if the joined output field names will be qualified with the name of the table the field came from.

  • Indexing the fields in the input layer or table view and Join Table on which the join will be based can improve performance. This can be done with the Add Attribute Index tool or by right-clicking the input in ArcCatalog and using the dialog box to add an index to the desired field.

    Learn more about performance tips for joining data

  • If the input layer or table view's fields were modified (renamed or hidden) using the Make Feature Layer or Make Table View tool Field Info parameter, these field modifications will not be carried forward to the output joined layer or table view.

  • The Join Table name cannot start with a numeric value.

    Learn about reasons why joining tables may fail

Syntax

AddJoin_management (in_layer_or_view, in_field, join_table, join_field, {join_type})
ParameterExplanationData Type
in_layer_or_view

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

Raster Catalog Layer; Mosaic Layer; Raster Layer; Table View
in_field

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

Field
join_table

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

Raster Catalog Layer; Mosaic Layer; Raster Layer; Table View
join_field

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

Field
join_type
(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

Code sample

AddJoin example 1 (Python window)

The following Python window script demonstrates how to use the AddJoin function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.MakeFeatureLayer_management ( "Habitat_Analysis.gdb/vegtype", "veg_layer")
arcpy.AddJoin_management( "veg_layer", "HOLLAND95", "vegtable.dbf", "HOLLAND95")
arcpy.CopyFeatures_management( "veg_layer", "Habitat_Analysis.gdb/vegjoin")
AddJoin example 2 (stand-alone script)

This stand-alone script shows the AddJoin function as part of a workflow to join a table to a feature class, then extract desired features.

# Name: AttributeSelection.py
# Purpose: Join a table to a featureclass and select the desired attributes

# Import system modules
import arcpy

try:
    # Set environment settings
    arcpy.env.workspace = "C:/data"
    arcpy.env.qualifiedFieldNames = False
    
    # Set local variables    
    inFeatures = "Habitat_Analysis.gdb/vegtype"
    layerName = "veg_layer"
    joinTable = "vegtable.dbf"
    joinField = "HOLLAND95"
    expression = "vegtable.HABITAT = 1"
    outFeature = "Habitat_Analysis.gdb/vegjoin"
    
    # Create a feature layer from the vegtype featureclass
    arcpy.MakeFeatureLayer_management (inFeatures,  layerName)
    
    # Join the feature layer to a table
    arcpy.AddJoin_management(layerName, joinField, joinTable, joinField)
    
    # Select desired features from veg_layer
    arcpy.SelectLayerByAttribute_management(layerName, "NEW_SELECTION", expression)
    
    # Copy the layer to a new permanent feature class
    arcpy.CopyFeatures_management(layerName, outFeature)
    
except Exception as err:
    print(err.args[0])

Environments

  • Current Workspace
  • Qualified Field Names

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Joins toolset
  • Working with layers and table views
  • About joining and relating tables

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal