i have the following categories DB structure
+----+---------------+-----------+
| id | category_name | parent_id |
+----+---------------+-----------+
| 1 | Category One | 0 |
| 2 | Category Two | 1 |
| 3 | Category Three| 1 |
| 4 | Category Four | 1 |
| 5 | Category Five | 1 |
| 6 | Category Six | 1 |
+----+---------------+-----------+
I have variable that contain one of child id for example category_id = 4 which have parent_id = 1
I want to get all parent subcategories including it self 4
I dont have parent ID, i have only category_id that have parent_category that i need
What i did so far
SELECT child.*
FROM `ec_categories` AS `child`
LEFT JOIN `ec_categories` AS `parent` ON `child`.`parent_id`=`parent`.`id`
WHERE `child`.`id` = '4'
Is there a way to get them using 1 query?