List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:July 16 2001 5:35pm
Subject:Re: problem with a LEFT JOIN
View as plain text  
SELECT ratings.memid, sites.*
FROM ratings LEFT JOIN sites
ON ratings.ID = sites.ID
WHERE ratings.memID = '1' and sites.ID IS NULL;

John Hawkins wrote:

> I'm having a bit of trouble doing a LEFT JOIN. Any input would be 
> greatly appreciated.
> 
> table 1 (sites, has approx 30 records) has a list of sites with the 
> following fields:
> ID, sitename, url
> 
> table 2 has (ratings, has approx 2020 records) has a list of member 
> ratings for the different sites with the following fields:
> ID, siteID, memID, rating
> 
> - sites.ID matches up with ratings.memID
> - memID is the ID of the member who performed this rating
> 
> I want to show the member who is logged in a list of all the sites that 
> he has not yet rated.
> 
> here is the select statement I have created, but isn't quite working:
> 
> SELECT sites.* FROM sites LEFT JOIN ratings ON sites.ID = ratings.siteID 
> WHERE ratings.memID != '1'
> 
> I am getting approx 2020 results (which, oddly enough, matches the 
> amount of records I have in the "ratings" table).
> 
> Like I said, any help would be greatly appreciated.
> 
> Best,
> 
> John
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <mysql-thread79764@stripped>
> To unsubscribe, e-mail 
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
gerald_clark@stripped

Thread
problem with a LEFT JOINJohn Hawkins16 Jul
  • Re: problem with a LEFT JOINGerald Clark16 Jul