"Simon Kimber" <[EMAIL PROTECTED]> wrote:
> I have written a PHP/MySQL "top-sites" program.  It has two tables,
> link_sites, which contains the details of all the sites signed up
> (ID,url,title,description) and link_stats in which a new record is
inserted
> every time a visitor links in from one of those sites
> (ID,siteID,clientIP,datestamp).
>
> Can anyone help me write a SQL query to pull out all the sites in
link_sites
> that are not mentioned in link_stats..  ie the ones that have never been
> clicked..

Read the manual about LEFT JOIN syntax.  In a nutshell you need something
like:

SELECT *
FROM link_sites
LEFT JOIN link_stats ON link_sites.ID=link_stats.ID
WHERE link_stats.ID IS NULL

In regular language, it means:

Look through *all* of the records from link_sites, join them with records
from link_stats with an ID that matches the ID from link_sites and then only
show records where there isn't a matching record in link_stats (in which
case it's NULL).

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to