Conversation
Contributor
|
Hmmm...
|
Collaborator
|
The rows need merging not updating; I’m not sure it can easily be done without a temp table. Can you expand on your suggestion Len? |
Contributor
|
@jfberry something like that START TRANSACTION;
UPDATE pokemon_stats SET pokemon_id = 65535 WHERE pokemon_id = 132;
INSERT INTO pokemon_stats (date, area, fence, pokemon_id, form_id, count)
SELECT
date,
area,
fence,
132 AS pokemon_id,
0 AS form_id,
SUM(count) AS count
FROM pokemon_stats
WHERE pokemon_id = 65535
GROUP BY date, area, fence
ON DUPLICATE KEY UPDATE
count = count + VALUES(count);
DELETE FROM pokemon_stats WHERE pokemon_id = 65535;
COMMIT;But yeah, just noticed its temporary table creation so it doesn't really matter. Either way we need to run it for multiple tables not single. |
Collaborator
|
Actually this approach might work even without moving the pokemon id since you can do form<>0 worth a go. |
dd14216 to
52735c1
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #347