SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    555
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to get products from all subcategories including the parent category ?

    Hi,

    I have this category / subcategory table, based on this what will be my query to get products from a specific top level category and all its subcategories ?

    Code:
    CREATE TABLE IF NOT EXISTS `categories` (
      `catg_id` mediumint(9) NOT NULL AUTO_INCREMENT,
      `catg_pid` mediumint(9) NOT NULL DEFAULT '0',
      `catg_name` varchar(30) NOT NULL,
      `catg_description` varchar(255) NOT NULL,
      `catg_status` tinyint(1) NOT NULL DEFAULT '1',
      PRIMARY KEY (`catg_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    maybe this will help... http://sqllessons.com/categories.html
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    555
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    Hi,

    Excellent. Works like a charm.

    Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •