Add Join (Data Management) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
Joins 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 only last for the duration of the session.
Illustration
Usage tips
The input must be a feature layer or a table view; it cannot be a feature class or table.
This tool is not limited ArcMap; it works on layers and table views in ArcCatalog and in scripts. The Make Feature Layer tool makes a layer for a feature class, and the Make Table View creates a table view from an input table or feature class.
The join table can be any of the following types of tables: a geodatabase table (ArcSDE, file or personal), a dBASE file, an INFO table, or an OLE DB table.
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.
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. 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".
The exceptions to the information above are coverage feature classes and INFO tables; the separator for these is a colon ":" instead of a period. For example, joining the layer "cov1_polygon", which has the Fields "COV#" and "COV-ID", to the Info table "info2.dat", which has fields "ID" and "DESC", will result in a layer with the following fields: "cov1_polygon:COV#", "cov1_polygon:COV-ID", "info2.dat:ID", and "info2.dat:DESC".
Records from the join table can be matched to more than one record in the input layer or table view.
If values in the join field are not unique, only the first occurrence of each value will be used.
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.
Another way to make the join permanent is to save the layer to a feature class or the input table view to a table.
No environment settings affect this tool.
Command line syntax
An overview of the Command Line window
AddJoin_management <in_layer_or_view> <in_field> <join_table> <join_field> {OUTER | INNER}
Parameter | Explanation | Data Type |
<in_layer_or_view> |
The layer or table view to which the join table will be joined. |
Table View | Raster Layer |
<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. |
Table View | Raster Layer |
<join_field> |
The field in the join table that contains the values on which the join will be based. |
Field |
{OUTER | INNER} |
Specifies what will be done with records in the input that match a record in the join table.
|
Boolean |
MakeFeatureLayer d:\workspace\California.mdb\road road_layer AddJoin road_layer roadcode d:\workspace\California.mdb\roadLookupTable roadcode CopyFeatures road_layer road2
Scripting syntax
About getting started with writing geoprocessing scripts
AddJoin_management (in_layer_or_view, in_field, join_table, join_field, join_type)
Parameter | Explanation | Data Type |
in_layer_or_view (Required) |
The layer or table view to which the join table will be joined. |
Table View | Raster Layer |
in_field (Required) |
The field in the input layer or table view on which the join will be based. |
Field |
join_table (Required) |
The table or table view to be joined to the input layer or table view. |
Table View | Raster Layer |
join_field (Required) |
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.
|
Boolean |
# 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: Select Data... gp.SelectData_management(ImportCAD_mdb, "CADStaging/Line") # Process: Make Layer... gp.MakeLayer_management(Line_fc, "lines_lyr", "", "", "EntID EntID VISIBLE;Shape_Length Shape_Length VISIBLE") # Process: Select Data2... gp.SelectData_management(ImportCAD_mdb, "Entity") # Process: Add Join... gp.AddJoin_management("lines_lyr", "EntID", Entity, "EntID", "OUTER", ) # 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 gp.GetMessages()