I have this MySQL tabel and I'm trying to get the ids of the main category and each subcategory linked to it and the others linked to this subcategories... You can see an example below:
+----------------------+
| Catrgorias |
+----------------------+
| id (int 11) |
+----------------------+
| nombre (varchar 255) |
+----------------------+
| parent (int 11) |
+----------------------+
+----+------------+--------+
| id | nombre | parent |
+----+------------+--------+
| 1 | Cat1 | NULL |
+----+------------+--------+
| 2 | Cat2. | NULL |
+----+------------+--------+
| 3 | SubCat1 | 1 |
+----+------------+--------+
| 4 | SubCat2 | 2 |
+----+------------+--------+
| 5 | SubSubCat1 | 3 |
+----+------------+--------+
Does anyone know how to get these ids in MySQL and get this result with something like this?
For categort_tree(1)
+----+ +-------+
| id | | id |
+----+ or +-------+
| 1 | | 1,3,5 |
+----+ +-------+
| 3 |
+----+
| 5 |
+----+
For categort_tree(2)
+----+ +-----+
| id | | id |
+----+ or +-----+
| 2 | | 2,4 |
+----+ +-----+
| 4 |
+----+