Joining Tables in SQL

by Dinesh 2012-08-27 17:24:55

Joining Tables in SQL


Each table contains specific information. At times, you might need to join two or more tables to retrieve the information you need. For example, if you look at the TrnAPDoc table, you will see that it contains the vendor ID; however, it does not contain the vendor name. If, when retrieving information from the APDoc table, you want to see the vendor name, you have to join the TrnVendor table to the TrnAPDoc table.

Syntax:
Explanation:
01. When you join two or more tables, a good idea is to precede the field names with the table names. This is not mandatory unless the same field name is found in more than one table.
02. If you precede the field name with a table name, place a period between the two names. For example, tablename.fieldname.
03. You must specify which fields are being joined.
04. If you do not specify which fields are being joined, the result is what is commonly referred to as a "Cartesian join" in which all rows in the first table are joined with all rows in the second table.
05. You can give each table name an alias, or alternative table name. When you assign an alias, you can then refer to the table by using its alias.
802
like
0
dislike
0
mail
flag

You must LOGIN to add comments