Database Reference
In-Depth Information
Figure 6.3
Two columns returned by the SELECT command.
SELECT DISTINCT
SELECT DISTINCT is a method of returning a unique set of data from your table. It is best
to only apply this SELECT to a specific column in your table. The format of this query is as
follows:
SELECT DISTINCT columnname
FROM
tablename
For example, you may remember that one of the pages that we have on our website was
our resume. If you refer back to Figure 6.1 you can see that this was page ID 4. We can use
SELECT DISTINCT to give us a list of the pages that have been viewed in our weblog table.
We don't need the quantity or number of times each page has been viewed, that can come
later, but we just need a list of pages that have been viewed. The following query will give us
such a list:
SELECT DISTINCT webpageid
FROM
log
The results of the above query are shown in Figure 6.4.
Figure 6.4
SELECT DISTINCT on the Log table.
Search WWH ::




Custom Search