Trying to understand multiple table queries...
Posted: Mon Feb 04, 2008 11:33 am
Hi, I am trying to compare three tables data with a single query. But one of the conditions doesn't seem to matter in the results.
My query is:
SELECT content.subcategories_id, titles.title, media.location, media.text
FROM content, media, titles
WHERE content.subcategories_id=7
AND content.type=2
AND titles.id=media.titles_id
GROUP BY media.id
ORDER BY media.id
Content is a table that holds ids to the requested media content in relation to the subcategory id, Media has information regarding the media file, Titles has the headline title for the media.
The problem seems to be that content.subcategories_id=7 doesn't appear to matter. It shows the results for all subcategories with media content.
Any help is very appreciated.
My query is:
SELECT content.subcategories_id, titles.title, media.location, media.text
FROM content, media, titles
WHERE content.subcategories_id=7
AND content.type=2
AND titles.id=media.titles_id
GROUP BY media.id
ORDER BY media.id
Content is a table that holds ids to the requested media content in relation to the subcategory id, Media has information regarding the media file, Titles has the headline title for the media.
The problem seems to be that content.subcategories_id=7 doesn't appear to matter. It shows the results for all subcategories with media content.
Any help is very appreciated.