Select Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Listed below this some of the Syntax for the Select Statement, what is the
AS correlation l correlation name?



Syntax
SELECT [DISTINCT | ALL] * | column
[AS correlation_name | correlation_name], [column...]

[INTO destination_table]

FROM table_reference
[AS correlation_name | correlation_name] [EXCLUSIVE]
 
The correlation name gives you a "short hand" that you can use when
referring to the table.

This can be useful if your table names are long:

SELECT MyLongTableName1.Field1, MyLongTableName1.Field2,
MyLongTableName1.Field3, MyLongTableName2.Field1, MyLongTableName2.Field2
FROM MyLongTableName1 INNER JOIN MyLongTableName2
ON MyLongTableName1.ID = MyLongTableName2.ID

can be written as

SELECT A.Field1, A.Field2, A.Field3, B.Field1, B.Field2
FROM MyLongTableName1 AS A INNER JOIN MyLongTableName2 AS B
ON A.ID = B.ID

or when you've got the same table more than once in your query:

SELECT Emp.Name, Emp.Number, Mgr.Name
FROM Employee AS Emp INNER JOIN Employee AS Mgr
WHERE Emp.ManagedByID = Mgr.ID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top