PDA

View Full Version : 2-3 table select


wyndom
03-22-2004, 06:59 PM
I Have 3 tables
-----------------
person
ID
person_name

product
ID
product_name

person_review
ID
product_ID
person_ID
---------------

Basically I a person reviews a product, their ID and the products ID gets put into the person_review table. I want to be able to go through the person_review table, and see what products haven't been reviewed, and what products haven't been reviewed by 'x' user.

So far, this has gotten me, what products a specific person HAS reviewed, but I am unable to get which ones they haven't reviewed.
SELECT DISTINCT person.person_name,products.product_name
FROM person, person_review,products
WHERE person.ID = person_review.person_ID
AND products.ID = person_review.product_ID
AND person.ID = 1
ORDER BY person.person_name

---

And this one, has gotten me which products have been reviewed in total, and by which person they were reviewed by.
SELECT person_name, product_name
FROM products, person, person_review
WHERE products.ID = person_review.product_ID
AND person.ID = person_review.person_ID

--

Basically I just want the opposite of the results these two are returning, though by sticking a != in different spots, I am still unable to get the results I want.

IF I am completely missing the boat here, I wouldn't be surprised, if there is an easier way to do this, please let me know.

oh and HI!