WITH RECURSIVE team(id, ParentCat_id) AS ( SELECt id, ParentCat_id FROM goods_goodcategory WHERe id = 4 UNIOn ALL SELECt sm.id, sm.ParentCat_id FROM goods_goodcategory AS sm, team AS t WHERe sm.id = t.ParentCat_id ) SELECt * FROM team

WITH RECURSIVE team(id, ParentCat_id) AS ( SELECt id, ParentCat_id FROM goods_goodcategory WHERe id = 4 UNIOn ALL SELECt sm.id, sm.ParentCat_id FROM goods_goodcategory AS sm, team AS t WHERe sm.id = t.ParentCat_id ) SELECt * FROM team