Partager via


How to: Add Tables to Views

You can access data stored in other tables by adding those tables to your local or remote view and specifying join conditions for the added tables.

Specifying join conditions between the tables you add help determine which records from the two tables should be compared and returned. For more information, see How to: Control Record Selection with Joins and Join Conditions for Tables, Queries, and Views.

Note

When you add tables to an existing view programmatically, the CREATE SQL VIEW command produces a cross product.

To add a table to a local view

  1. Open the view in the Project Manager or Database Designer.

    The View Designer opens.

  2. On the Query menu, click Add Tables.

  3. In the Add Table or View dialog box, select the table or view you want to add.

    The table or view you selected appears in the View Designer.

  4. In the Join Condition dialog box, specify the join condition you want, and click OK.

  5. If you want to specify an alias for each table that you select, type it in the Alias box.

  6. When you are finished, click Close.

For more information, see Query and View Designers and Join Condition Dialog Box.

To add a table to a remote view

  1. Open the view in the Project Manager or Database Designer.

    The View Designer opens.

  2. On the Query menu, click Add Tables.

  3. In the Open dialog box, click each table you want to add, and then Add.

    The table you selected appears in the View Designer.

  4. In the Join Condition dialog box, specify the join condition you want, and click OK.

  5. If you want to specify an alias for each table that you select, type it in the Alias box.

  6. When you are finished, click Close.

For more information, see Query and View Designers, Select Connection or Data Source Dialog Box and Join Condition Dialog Box.

To add a table to views programmatically

  1. In the SQL SELECT statements specified by the CREATE SQL VIEW command, add table names and join conditions for the tables you add using the FROM and WHERE clauses.

    Visual FoxPro displays a confirmation dialog box to overwrite the existing view.

  2. In the confirmation dialog box, click Yes.

For more information, see CREATE SQL VIEW Command.

See Also

Tasks

How to: Edit Views

How to: Select Fields for Views

Other Resources

Creating Views

Working with Views (Visual FoxPro)