Page 1 of 1

Need Join Help

Posted: Wed Sep 22, 2010 4:00 pm
by thinsoldier
Hi, could someone help me with a join query.

I've included a simplified diagram of my database and my query so far which doesn't work
Image

Code: Select all

SELECT house.id, house.propertyname
FROM
  residences AS house,
  residents_to_residences AS r2r,
  residents AS person
WHERE residence_id != house.id
GROUP BY house.id
  ORDER BY house.propertyname

Re: Need Join Help

Posted: Thu Sep 23, 2010 4:35 am
by VladSun
You need to LEFT join these tables and filter the records with resident_to_residences data is NULL