VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-Cart StoreFront Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 SQL Statement Category and SubCat
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Kingdom
14 Posts

Posted - February 24 2012 :  02:13:30  Show Profile  Visit bradrob's Homepage  Reply with Quote

Just a quick question i would like a little help with if anyone has a simple answer, all i want to do is select all products from the products table for a particular categoryid and also products for a highercatalogid match so that it will display all of the products from one category and sub categories below it.

so first i would need to query the categories table for any categories that have a highercategoryid the same as the category you are loading, and then query the products table for the 2 different categoryid (the main cat and subcat) and display all products as normal.

i found a tutorial on the internet for an SQL subquery statement but i'm not sure whether this will accomplish what i need, this is the sample they give.

SELECT id, first_name FROM student_details WHERE first_name IN (SELECT first_name FROM student_details WHERE subject= 'Science');

Would anybody know if this could do the job.


VP-ASP Expert

731 Posts

Posted - March 10 2012 :  05:07:54  Show Profile  Reply with Quote
select * from products a, categories b where a.ccategory = 10 and a.ccategory = b.categoryid

this is example to get list of products that have category id 10.

could be something like this to display the products frm main cat.

Go to Top of Page

VP-ASP Expert

United Kingdom
948 Posts

Posted - April 02 2012 :  09:03:00  Show Profile  Reply with Quote
or use the prodcategories table to get the all the products listed for any categories that you want:

SELECT DISTINCT intcatalogid AS catalogid FROM prodcategories WHERE intcategoryid IN (10,53,101,127..... etc)


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000