Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2010
    Posts
    39

    Unanswered: categories and sub categories in mysql

    Dear friends,

    I am trying to build application in php which have category and subcategories till 3rd level. Please show me example ? Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so you have a self referncing foreign key

    tbl:Persons
    ID
    Title
    Forenames
    ......
    ManagerID 'nullable FK references tblPersons.ID

    then you have your query....
    its dumb but I forget the correct syntax, it should be something sort of similar to
    select my,column,list from Persons as A
    right join Persons as B on b.ID = a.ManagerID
    right join Persons as C on C.ID = b.ManagerID
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    please, use left outer joins, not right outer joins

    this might help --> Categories and Subcategories
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    itsafaircopyerhooner
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jul 2010
    Posts
    39
    Thanks r937,

    I have learned a lot from you, that's anothor great things, it look like your own site, please write more tutorials on sql i have added that site to my favourite. Thanks

Tags for this Thread

Posting Permissions

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