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.
Below is a query I am working on...
$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
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?!
If that's all you want to do with the query, then use an INNER JOIN.
To me, this last part doesn't make sense
I meant that I was originally thinking of doing a RIGHT OUTER JOIN, finding all Sections that the Article "postage-meters-can-save-you-money" was located in (e.g. "Finance" and "Operations"), and then maybe use the SQL "IN" keyword/whatever to see if the "Section" in the URL was "inside of" the list of all Sections that are associated with the Article.
But after I made my original post, I decided to do what you aid above, and just went with an INNER JOIN.
This topic is now closed. New replies are no longer allowed.