I have two mysql tables, users and pages. I want to find out how many distinct referrers there are, that are not robots. But because the robots identifier is in the users table, and the referrers in the pages table, I need to do a multiple select in MySQL...
This works, but doesn’t distinguish the non-robots pages (gets them all):
"select distinct referrer from pages where page_start_time>'$timeframe1' and page_finish_time<'$timeframe2' and page_visit_order='1' limit $limit_visitors_start,$visitors_show";
// The page_visit_order='1' is so I only get the referrer from the first page of their visit, i.e. one referrer per visit per visitor
This is what I want, but it doesn’t work properly... Can anyone see anything obviously wrong?
"select distinct pages.referrer from user, pages where page_start_time>'$timeframe1' and page_finish_time<'$timeframe2' and page_visit_order='1' and page_user_id=user_id and robot='N' limit $limit_visitors_start,$visitors_show"";
It seems to give me duplicate entries.
Another question in relation to this is how does mysql order the SELECT queries, I mean, should I have the select a certain timeframe first, or last? Whats faster? I tried reading up on it in MySQL, but it didn’t make any sense to me...
Cheers,