The Make Query Table tool applies an SQL query to a database and the results are represented in a layer or table view. The query can be used to join several tables or return a subset of columns or rows from the original data in the database.
Make Query Table accepts data from an ArcSDE geodatabase, a file geodatabase, a personal geodatabase, or an OLE DB connection.
The layer that is created by the tool is temporary and will not persist after the session ends unless the document is saved.
Usage tips
-
All input feature classes or tables must be from the same input workspace.
-
If a Shape column is added to the field list, the result is a layer; otherwise, it is a table view.
-
If the output result is a layer, it may be persisted to a layer file using the Save To Layer File tool or to a feature class using the Copy Features tool.
-
The order of the fields in the field list indicates the order the fields will appear in the output layer or table view.
-
The tool allows you to provide a key field option and key fields list. This information defines how rows are uniquely identified and is used to add a dynamically generated ObjectID column to the data. Without an ObjectID column, selections will not be supported.
-
The key fields list lets you choose several columns if the combination of these columns is needed to define unique values.
-
If an SQL expression is used but returns nothing, the output feature class will be empty.
-
Feature classes can be joined, but the fields list must contain at most one field of type geometry. If you add more than one geometry column, the tool will error when you click OK.
-
For details on the syntax for the Expression parameter, see Building an SQL Expression or SQL Reference.
-
The Fields and Key Fields parameters' Add Field button is used only in ModelBuilder. In ModelBuilder, where the preceding tool has not been run, or its derived data does not exist, the Fields and Key Fields parameters may not be populated with field names. The Add Field button allows you to add expected field(s) so you can complete the Make Query Table dialog and continue to build your model.
-
When input tables are from a file geodatabase, tables generally join in the order listed in the Input Tables parameter. For example, if Table1 is listed before Table2, Table2 will be joined by getting a row from Table1, then getting matching rows from Table2. However, if this would result in querying Table2 on an un-indexed field, and reversing the order would result in querying Table1 on a indexed field, the order will be reversed in an attempt to maximize performance. This is the sole query optimization logic at work when you're using file geodatabase data with this tool. In general, joins in file geodatabases perform best when they are one-to-many and one-to-one.
-
The following environment settings affect this tool: workspace, scratch workspace, Extent, M Domain, Configuration keyword, Coordinate system, Output has M values, Output spatial grid, Output has Z values, Default Z value, Output XY domain, and Output Z domain.