Created
December 8, 2015 07:10
-
-
Save duyet/8f340b64225b84cb639c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
t1.id as level_1, | |
t4.level_2, | |
t4.level_3 | |
FROM | |
`categories` t1 | |
LEFT JOIN ( | |
SELECT | |
t2.id as level_2, | |
t2.parent_id as level_2_parent_id, | |
t3.id as level_3 | |
FROM | |
`categories` t2 | |
LEFT JOIN `categories` t3 ON t2.id = t3.parent_id | |
) as t4 ON t1.id = t4.level_2_parent_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment