On my website, an "Article" can be in different "Sections", and a "Section" can have many "Articles".
When a user selects an Article, I want to be sure that the URL has a valid "Section" for the given "Article" and visa-versa, e.g.
http://local.debbie/finance/articles/postage-meters-can-save-you-money
Below is a query I am working on...
Code SQL:$q1 = 'SELECT id, title, description, keywords, heading, sub_heading, published_on, author, body, reference_listing, endnote_listing FROM article AS a RIGHT OUTER JOIN article_section AS a_s ON a.id = a_s.article_id WHERE slug=? AND a_s.section_id=?';
If I want to check that the Article "postage-meters-can-save-you-money" is in the "finance" Section (along with possibly other Sections), how do I need to modify the above query??
Do I want an INNER JOIN looking for an exact match, or a RIGHT OUTER JOIN just making sure the "Section" is in set of all Sections related to the Article?
Hope that makes sense?!
Thanks,
Debbie




Reply With Quote



Bookmarks