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 <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
[EMAIL PROTECTED]


---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to