Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
If tables are joined, the Query and View Designer Tools (Visual Database Tools) represents the join graphically in the Diagram pane (Visual Database Tools) and by using SQL syntax in the SQL Pane (Visual Database Tools).
Diagram pane
In the Diagram pane the Query and View Designer displays a join line between the data columns involved in the join. The Query and View Designer displays one join line for each join condition. For example, the following illustration shows a join line between two tables that are joined:
If tables are joined using more than one join condition, the Query and View Designer displays multiple join lines, as in the following example:
If the joined data columns aren't displayed (for example, the rectangle representing the table or table-structured object is minimized or the join involves an expression), the Query and View Designer places the join line at the title bar of the rectangle representing the table or table-structured object.
The shape of the icon in the middle of the join line indicates how the tables or table-structured objects are joined. If the join clause uses an operator other than equal (=), the operator appears in the join line icon. The following table lists the icons that appear in the join line.
| Join line icon | Description |
|---|---|
|
Inner join (created using equal = sign). |
|
Inner join based on the "greater than" > operator. |
|
Outer join in which all rows from the table represented on the left are included, even if they don't have matches in the related table. |
|
Outer join in which all rows from the table represented on the right are included, even if they don't have matches in the related table. |
|
A full outer join in which all rows from both tables are included, even if they don't have matches in the related table. |
The symbols on the ends of the join line indicate the type of join. The following table lists the types of joins and the icons displayed on the ends of the join line.
| Icon on ends of join line | Type of join |
|---|---|
|
One-to-one join. |
|
One-to-many join. |
|
Query and View Designer can't determine the join type. This situation occurs most often when you have created a join manually. |
SQL pane
A join can be expressed in a number of ways in a SQL statement. The exact syntax depends on the database you're using and on how you have defined the join.
Syntax options for joining tables include:
JOINqualifier for theFROMclause. The keywords INNER andOUTERspecify the join type. This syntax is standard for ANSI 92 SQL.For example, if you join the
publishersandpub_infotables based on thepub_idcolumn in each table, the resulting SQL statement might look like this:SELECT * FROM publishers INNER JOIN pub_info ON publishers.pub_id = pub_info.pub_id;If you create an outer join, the words
LEFT OUTERorRIGHT OUTERappear in place of the word INNER.WHEREclause compares columns in both tables. AWHEREclause appears if the database doesn't support theJOINsyntax (or if you entered it yourself). If the join is created in theWHEREclause, both table names appear in theFROMclause.For example, the following statement joins the
publishersandpub_infotables.SELECT * FROM publishers, pub_info WHERE publishers.pub_id = pub_info.pub_id;