how can i get this answer + a query in mysql -


i have table category in database in form

catid   cattitle    catparent 1       electronics     0 2       laptop          1 3       mobile          1 4       hp              2 5       hp-dv6          4 6       nokia           3 

how can catid 's parent of hp-dv6 ? (1,2,4,5)

thanks


no didn't worked when choosing hp-dv6 want informations:

catid   cattitle    catparent 1       electronics     0 2       laptop          1 4       hp              2 5       hp-dv6          4 

electronics -> laptop -> hp -> hp-dv6 -> model_no ....

number of sub cats not specified

there's no recursion built in mysql. instead, choices include

  • joining table possibly required
  • switching model (e.g. nested set)
  • handling recursion @ application level (e.g. bit of php)

Comments