How to create a self-join (Enterprise Manager)

To create a self-join

  1. Add to the Diagram pane the table you want to work with.
  2. Add the same table again, so that the Diagram pane shows the same table in two input source windows.

    The Query Designer assigns an alias to the second instance by adding a sequential number to the table name. In addition, the Query Designer creates a join line between the input source windows based on the primary key. In most cases, this join can function as the second join condition.

  3. Right-click the join line between the tables, choose Properties from the shortcut menu, and then change the comparison operator between the primary keys as required. For example, you might change the operator to less than (<).

    Create the primary join condition by dragging the name of the primary join column in the first input source window and dropping it on the corresponding column in the second input source window.

  4. Specify other options for the query such as output columns, search conditions, and sort order.

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.