Last active
September 25, 2018 10:49
-
-
Save sandyGanoti/f34366f70e647dafd6836b3909948b1e to your computer and use it in GitHub Desktop.
queries for score_group update
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
-- 1. The following query populates the user_ids with a comma-separated value of some user_ids (some is specified inside the substring_index function) on survived score_group | |
update score_group set user_ids=(select substring_index(GROUP_CONCAT(user_id SEPARATOR ','), ',', 3) as expecting_ids from user_leaderboard where leaderboard_id=score_group.leaderboard_id and name='Survived') where leaderboard_id in (select id from leaderboard); | |
---------------- | |
-- 2. The following query updates the survived score groups with the number of users that belong to its leaderboard | |
update score_group set no_of_users=(select count(*) from user_leaderboard where leaderboard_id=score_group.leaderboard_id) where leaderboard_id in (select id from leaderboard) and name='Survived'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment