Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked tables

Status
Not open for further replies.

apapet

Programmer
Feb 2, 2000
1
FR
Hi,<br>
<br>
Do you know if it is possible to link table in SQL Server as like it is possible in MSAccess ?<br>
<br>
Thanks in advance.<br>
<br>
Alain.
 
This is called a &quot;join&quot; and is used when you want to combine information from two or more tables into one result set. First, the two tables must have a common field, such as &quot;emp_id&quot;. Suppose the table &quot;employees&quot; has two fields, one is &quot;emp_id&quot; and the other is &quot;lname&quot;.&nbsp;&nbsp;Further, suppose the table &quot;addresses&quot; has two fields, one is &quot;emp_id&quot; and the other is &quot;city&quot;. If you want to obtain a result set consisting of the employee last name and the city they live in, you would write your query like this:<br><br>select lname, city<br>from employees, addresses<br>where employees.emp_id = addresses.emp_id<br><br>There are other factors involved, such as, if the column name appears in both tables, you must qualify the column name with the table name, and aliasing the table names can shorten your query, but that's the gist of it.<br><br>Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top