summaryrefslogtreecommitdiff
path: root/docs/useful-sql.md
blob: 64de12821ca22d22155a4a50a797dd2a37f7794a (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
);
```