Re: SQL Hell
| From: | Curt Zirzow | Date: | Thu, 22 Apr 2004 03:18:02 +0000 |
| Subject: | Re: SQL Hell | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184181@lists.php.net to get a copy of this message | ||
* Thus wrote Marc Greenstock (marc@shockmedia.com.au):
> Hi all,
>
> Wondering if someone could help me with an sql statement
>
> MySQL version 4.0.18
>
> I have three tables:
> 1. visitor_data (Visitor_ID, IP Address)
> 2. visit_data (Visit_ID, Visitor_ID)
> 3. page_data (Page_ID, Visit_ID, Visitor_ID, URI)
>
> If you look closely you can see the relationship in these tables and you
> might guess I'm tracking what a user is doing on this site.
This really should be asked on a mysql list.
select pg.Page_ID, pg.Visit_ID, pg.Vistor_ID, pg.URI
from vistor_data vrd, visit_data vd, page_data pg
where vrd.Visitor_ID = vd.Visitor_ID
and vd.Visit_ID = pg.Visit_ID
As loong as
vrd.Vistor_ID, vd.Visit_ID are unique
and
pg.Visit_ID is indexed
You'll performance wont be an issue.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."