Created
November 20, 2019 12:54
-
-
Save elieux/9a1444df52ab48250d6e242aeffaf12d to your computer and use it in GitHub Desktop.
Weird MySQL index thing
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 main.id, ( | |
SELECT SUM(group_member.col) | |
FROM tbl AS group_member | |
WHERE main.id = group_member.id OR main.parent_id > 0 main.parent_id = group_member.parent_id | |
) AS col_sum | |
FROM tbl AS main | |
ORDER BY id DESC | |
LIMIT 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment