テーブル'tourneyteamsISF'フィールド'pointsfavor'および'pointscontra'をテーブル'tourneygamesISF'フィールド'op1score'および'op2score'から特定のIDから更新したい。
例えば:
Table name = tourneygamesISF
op1(name of row) vs. op2 - op1score = 25 - op2score = 20
これを更新したい:
op1: (from: tourneygamesISF) = ID in tourneyteamsISF
+ pointsfavor = 25 (to: tourneyteamsISF)
+ pointscontra = 20 (to: tourneyteamsISF)
op2: (from: tourneygamesISF) = ID in tourneyteamsISF
+ pointsfavor = 20 (to: tourneyteamsISF)
+ pointscontra = 25 (to: tourneyteamsISF)
今までに次のものがあります
UPDATE tourneyteamsISF
INNER JOIN tourneygamesISF g1 ON (tourneyteamsISF.ID = g1.op1)
INNER JOIN tourneygamesISF g2 ON (tourneyteamsISF.ID = g2.op2)
SET pointsfavor = pointsfavor
+ IF(g1.op1score > g1.op2score, g1.op1score - g1.op2score, 0)
+ IF(g2.op2score > g2.op1score, g2.op2score - g2.op1score, 0)
, pointscontra = pointscontra
+ IF(g1.op1score < g1.op2score, g1.op2score - g1.op1score, 0)
+ IF(g2.op2score < g2.op1score, g2.op1score - g2.op2score, 0)
WHERE ID = 1;
ただし、エラーが発生します。where句の列'ID'があいまいです。
私のテーブルは次のようなものです。
TABLE tourneyteamsISF
ID integer autoincrement primary key,
name varchar,
pointsfavor integer,
pointscontra integer
TABLE tourneygamesISF
ID integer autoincrement primary key,
op1 integer,
op2 integer,
op1score integer, /*score for team1*/
op2score integer /*score for team2*/
テーブルチームとゲームのIDに名前を付けることと関係があることは知っていますが、行き詰まって混乱しています。私が得ることができるすべての助けに感謝します。