我必须在两张不同的桌子之间乘以两个勇敢者。
TABLE NAME match_serie_a
id journee equipe_A equipe_B quote_1 quote_N quote_2 resultat date
2 38 Juventus Lecce 1.25 3.5 6.9 1 2020-06-27
TABLE NAME pari
id_Joueur id_Match montant_pari type_pari Gagne montant_gain
4 2 10 1 oui NULL
现在,我应该将表“pari”中的“montant_pari”与表“match_serie_a”中的“quote_1”相乘,并将结果存储在“montant_gain”中。
做那件事最好的要求是什么?
一种方法使用相关子查询:
update table2 t2
set montant_gain = (select t2.montant_pari * t1.quote_1
from table1 t1
where t1.id = t2.id_match -- I am guessing this is used to match rows
);