Return Column Function
Return Column Function
2 ReturnColumnDescription
The ReturnColumnDescription describes the columns, or combination of columns, to
return. It can be any of the following:
* (indicating all columns)
The name of a column
An expression involving column names, enclosed in brackets, along with strings
and string operators; for example, [PubID] & "- " & [Title]
(Note that, according to the syntax of the SELECT statement, ReturnColumnDescription
can be repeated as many times as desired.)
When two returned columns (from different tables) have the same name, it is necessary to
qualify the column names using the table names. For instance, to qualify the PubID
column name, we write BOOKS.PubID and PUBLISHERS.PubID. We can also write
BOOKS.* to indicate all columns of the BOOKS table.
Finally, each ReturnColumnDescription can end with:
[AS AliasName]
to give the return column a (new) name.
For example, the following statement:
SELECT DISTINCTROW
[ISBN] & " from " & [PubName] AS [ISBN from PubName]
FROM PUBLISHERS INNER JOIN BOOKS ON PUBLISHERS.PubID = BOOKS.PubID;
returns a single column result table ISBN-PUB, as shown in Table 6.10.
Table 6.10. The ISBN-PUB Table
ISBN from PubName
0-12-345678-9 from Small House
0-11-345678-9 from Small House
0-321-32132-1 from Small House
0-55-123456-9 from Small House
0-12-333433-3 from Big House
0-103-45678-9 from Big House
0-91-335678-7 from Big House
0-99-999999-9 from Big House
1-22-233700-0 from Big House
1-1111-1111-1 from Big House
0-91-045678-5 from Alpha Press
0-555-55555-9 from Alpha Press
0-99-777777-7 from Alpha Press
0-123-45678-0 from Alpha Press
Not only does the AS AliasName option allow us to name a "compound column," it also
allows us to rename duplicate column names without having to qualify the names.