Determine if Article is in results?

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…

			$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

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 :wink:

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.

Follow me?

But after I made my original post, I decided to do what you aid above, and just went with an INNER JOIN.

Thanks,

Debbie