1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/bash
DBNAME=$1
PLAYERSDB=${LIGA_PLAYERS_DB_NAME}
echo $DBNAME
cat .cezar-teams-$DBNAME | while read TEAM CEZARTEAM
do
echo "UPDATE teams SET internet = $CEZARTEAM WHERE id = $TEAM;"
done | mysql ${LIGA_MYSQL_CONNECTION_OPTS} $DBNAME
QUERY="SELECT dmppl.link, CONCAT(dmppl.gname, ' ', dmppl.sname), TRIM(t.shortname), TRIM(pl.loc2), CONCAT(lineup.rnd, '-', lineup.segment) FROM $DBNAME.players dmppl JOIN $DBNAME.teams t ON t.id = dmppl.team JOIN (
SELECT rnd, segment, openN as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, openS as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, openE as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, openW as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, closeN as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, closeS as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, closeE as pl FROM $DBNAME.segments
UNION
SELECT rnd, segment, closeW as pl FROM $DBNAME.segments
) lineup ON lineup.pl = dmppl.id LEFT JOIN $PLAYERSDB.players pl ON dmppl.link = pl.ID
WHERE COALESCE(t.internet, '') <> COALESCE(pl.info, '')
ORDER BY dmppl.link, lineup.rnd, lineup.segment;"
echo $QUERY | mysql ${LIGA_MYSQL_CONNECTION_OPTS} -N
|