Quote:
|
Originally Posted by stephank
FROM CATEGORIES_PEOPLE, PEOPLE_IMAGES
INNER JOIN PEOPLE ON CATEGORIES_PEOPLE.PEOPLEID = PEOPLE.ID
INNER JOIN CATEGORIES ON CATEGORIES_PEOPLE.CategoryID = CATEGORIES.ID
INNER JOIN IMAGES ON PEOPLE_IMAGES.IMAGESID = IMAGES.ID
|
please, don't do that
you are mixing the old style comma joins with the new style JOIN syntax
first of all, if you already know which category (based on your WHERE clause), then you do not need the CATEGORIES table at all
this also means you should start your joins at the CATEGORIES_PEOPLE table
Code:
FROM categories_people
INNER
JOIN people
ON people.id = categories_people.peopleid
INNER
JOIN people_images
ON people_images.peopleid = people.id
INNER
JOIN images
ON images.id = people_images.imagesid
WHERE categories_people.categoryid = 1
please note carefully the sequence of tables in the joins
also, note that if categoryid is numeric, you want to compare it to the number 1, not the string '1'