SELECT a.category_id, a.category FROM test a, test b WHERE b.main_category = a.category_id