with t as(select * from category where categoryid = 1 union all select category.* from t, category where t.categoryid = category.parentid ) select * from t