[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

SQL SELECT query needed

Asked by christamcc in SQL Query Syntax

Tags: sql

I need a SELECT query please.

PHP shopping website

Here's the db schema that you need:

Table PRODUCTS
Product_ID PK
Category_ID FK to Category_ID in CATEGORIES TABLE

Table CATEGORIES
Category_ID PK
Parent_ID

Hmm, how to explain?  Categories can be many levels deep or only one level deep like this
Hats (Category_ID #1, Parent_ID #0 (0 means top level))
-Rimmed Hats (Category_#2, Parent_ID #1 (meaing sub of Hats)
---Straw Rimmed Hats (Category_ID #3, Parent_ID #2 (meaning sub of Rimmed Hats)
-----=Large Rimmed Hat with Ribbon (Product_ID #1, Category_ID #3)
---More Straw Rimmed Hats (Category_ID #4, Parent_ID #3 (meaning sub of Straw Rimmed Hats)
------Dyed Hats (Product_ID #5, Category_ID #4)
------------= Red Dyed Hat (Product_ID #2, Category_ID #5)

Glasses (Category_ID #6, Parent_ID #0)
--= DG Gold Rimmed Glasses (Product_ID #3, Category_ID #6)
--= Plastic Revlon Glasses (Product_ID #4, Category_ID #6)

I need a SELECT query that will select all the products in all the subcategories of a category no matter what level of category i'm in.  If it was two levels only I could do something like:

SELECT p.products_id  FROM PRODUCTS  p
        WHERE p.categories_id = '" . (int)$current_category_id . "'
OR p.categories_id in  (select categories_id from categories where parent_id =  '" . (int)$current_category_id . "

It doesn't have to be only one query and feel free to incorporate any php.  Just something that works and is efficient.

thanks!
Christa
[+][-]07/02/09 06:50 PM, ID: 24769285Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/02/09 07:03 PM, ID: 24769323Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/02/09 11:37 PM, ID: 24770393Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07/07/09 08:49 PM, ID: 24800419Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/13/09 03:11 PM, ID: 24844488Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/14/09 12:18 AM, ID: 24846911Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: SQL Query Syntax
Tags: sql
Sign Up Now!
Solution Provided By: christamcc
Participating Experts: 2
Solution Grade: A
 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625