Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Return Column Function

The ReturnColumnDescription describes the columns returned by a SELECT statement. It can specify all columns, a single column, or an expression combining columns. Column names can be qualified with the table name if two tables have identically named columns. Each ReturnColumnDescription can also specify an alias name using the AS keyword to rename columns. For example, an expression combining two columns can be given a new column name as an alias.

Uploaded by

mihaelahristea
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Return Column Function

The ReturnColumnDescription describes the columns returned by a SELECT statement. It can specify all columns, a single column, or an expression combining columns. Column names can be qualified with the table name if two tables have identically named columns. Each ReturnColumnDescription can also specify an alias name using the AS keyword to rename columns. For example, an expression combining two columns can be given a new column name as an alias.

Uploaded by

mihaelahristea
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

6.7.3.

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.

You might also like