Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Explanation of Statement

Author  Topic 

cfs566
Starting Member

1 Post

Posted - 2014-05-28 : 15:54:26
Hi, I am new to SQL and am running script already written and want to understand them so I can become more proficient in SQL. The script I have been running is:
select ct.contract, ct.shipper, c.companyname
from company c
inner join contract ct on c.company = ct.shipper
and ct.contract IN ('3999306','2178','3999302','3135') -- INPUT CONTRACT HERE


I understand very basic, but don't understand the ct.(x) and the from company c with the join.

tks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-05-28 : 15:59:59
c and ct are aliases. c=company and ct=contract. So you could write company.companyname or c.companyname. It's just saving some typing, but it does cause you to have to lookup which is which at times. Some people really love them (me), others don't.

A join is way is to gather data from a related table, typically joining on the primary key and foreign keys of the tables, but not always.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -