Database Reference
In-Depth Information
Figure 6.9
Selecting the same column twice.
SELECT id,id
FROM
webpage
As you will expect, the above query produces a result as shown in Figure 6.9.
However, it may be that later in the query we need to perform some calculation on one
of those columns. How are we to tell the difference between the two? As both columns are
called id that would be difficult. To solve this problem SQL allows the use of aliases, that is,
the renaming of a column by use of the AS keyword.
To use this we would modify the above code as follows:
SELECT
id,id AS pageid
FROM
webpage
You can compare the different results of the two queries by examining Figures 6.9 and 6.10.
Figure 6.10
Selecting the same column twice with an alias.
Search WWH ::




Custom Search