Search Posts

Get Category Level [duplicate]

how to – Get Category Level [duplicate]

This question already has an answer here:

In MySql I have category table with fields:

  • cat_id (int)
  • cat_parent_id (int)
  • cat_name (string)

How to create query that return list off all categoryes with coresponded level number

cat parent_id for root nodes is 0

sample SQL Fiddle with sample data :!9/ba439ae/3

I have MySql version : 5.7.19 and Fiddle is on 5.6

Source: Stackoverflow

Leave a Reply

Your email address will not be published. Required fields are marked *