Home

SQL Keyword: AS

 

Description

The AS keyword is used in a SELECT statement to specify the caption of a field.

Examples

Here is an example that applies the AS keyword to a field:

SELECT DateHired AS EmployedSince, LastName, HourlySalary
FROM Employees;

Here are two examples of using the AS keyword:

SELECT DateHired AS [EmployedSince], LastName, HourlySalary AS [Pay Rate]
FROM Employees;

You can also include the string in single-quotes. Here are two examples:

SELECT DateHired AS [EmployedSince], LastName, HourlySalary AS 'Pay Rate'
FROM Employees;

Here is an example:

Private Sub cmdDataSource_Click()
    RecordSource = "SELECT Employees.DateHired, " & _
                   "       Employees.LastName + ', ' + " & _
                   "       Employees.FirstName As FullName, " & _
                   "       Employees.Department " & _
                   "FROM Employees;"

    txtDateHired.ControlSource = "DateHired"
    txtFullName.ControlSource = "FullName"
    txtDepartment.ControlSource = "Department"
End Sub

Here is another example:

SELECT Employees.DateHired,
       [FirstName] & " " & [MiddleName] & " " & [LastName] AS Employee
FROM   Employees;

Here is an example that uses a Left() function:

SELECT Employees.DateHired,
       [FirstName] & " " & Left([MiddleName],1) & " " & [LastName] AS Employee
FROM   Employees;

Here is another example that uses a function:

SELECT Employees.DateHired,
       IIf(IsNull([MiddleName]),
           [FirstName] & " " & [LastName],[FirstName] & " " & 
	   UCase(Left([MiddleName],1)) & " " & [LastName]) AS Employee
FROM Employees;

 

 
 
     
 

Home Copyright © 2009-2016, FunctionX, Inc.