Created
December 23, 2018 12:22
-
-
Save Kcko/8c9ab3e1ef90529fd79e5babd01fa77e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select l0.catID, | |
concat( | |
case when l5.catID is null then '' else concat(l5.category, '/') end | |
, case when l4.catID is null then '' else concat(l4.category, '/') end | |
, case when l3.catID is null then '' else concat(l3.category, '/') end | |
, case when l2.catID is null then '' else concat(l2.category, '/') end | |
, case when l1.catID is null then '' else concat(l1.category, '/') end | |
, l0.category) | |
from catcat l0 | |
left join catcat l1 on l0.parentID=l1.catID | |
left join catcat l2 on l1.parentID=l2.catID | |
left join catcat l3 on l2.parentID=l3.catID | |
left join catcat l4 on l3.parentID=l4.catID | |
left join catcat l5 on l4.parentID=l5.catID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment