Database Reference
In-Depth Information
Figure 7.6
The completed equi-join query.
have done the same with the webpage 's title column so that what we are referring to
becomes clearer.
You will also notice that we do not have to return a column that we use in the match con-
ditions. In our example, we used webpage.id in the match query but filtered that column out
of the actual results by not specifying it in our output column list after the SELECT key-
word.
Equi-joins on More Tables
To demonstrate further, you can use an equi-join to inner join more than one table. We will
now join the results we obtained above with the cookie table, so that we can get the date that
the person viewing the page first looked at our site. This will show if they are visiting for the
first time or have come back to look again. To do this we will take the above query and add
another column match clause to the WHERE statement, and rename a few columns for clar-
ity:
SELECT
log.id as logid,
webpage.title AS pagetitle,
log.browser,
log.datecreated AS logdate,
log.ipnumber,
log.referringpage,
cookies.datecreated AS cookiecreated
FROM
log, webpage, cookies
WHERE
webpage.id = log.webpageid
AND cookies.cookieid=log.cookieid
Figure 7.7 shows this query working. By comparing the datestamp of the log column,
alias logdate , with the cookie creation date, alias cookiecreated , we can now see if the viewer
is looking at the site for the first time or returning.
Search WWH ::




Custom Search