summaryrefslogtreecommitdiff
path: root/docs/useful-sql.md
blob: 32a8f5b9dccce969dca10905ee1780b421b567bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Update categories from current `players` table:

```
UPDATE rankings
JOIN players
     ON players.id = rankings.pid
SET rankings.region = players.region,
    rankings.flags = players.flags
WHERE rankings.date = '#DATE#';
```

After importing ranking CSV to `temp_rankings`, copy to `rankings` with current categories:

```
INSERT INTO rankings (
       SELECT pid, `date`, place, score, region, flags \
       FROM temp_rankings
       JOIN players
            ON players.id = temp_rankings.pid
);
```