从两个不同的表中乘法并更新两个值

wooyq4lh  于 2021-08-01  发布在  Java
关注(0)|答案(1)|浏览(309)

这个问题在这里已经有了答案

mysql使用其他表中的信息更新字段(1个答案)
10个月前关门了。
我必须在两张不同的表之间乘以两个值。

  1. TABLE NAME match_serie_a
  2. id journee equipe_A equipe_B quote_1 quote_N quote_2 resultat date
  3. 2 38 Juventus Lecce 1.25 3.5 6.9 1 2020-06-27
  4. TABLE NAME pari
  5. id_Joueur id_Match montant_pari type_pari Gagne montant_gain
  6. 4 2 10 1 oui NULL

现在,我应该将表“pari”中的“montant\u pari”与表“match\u serie\u a”中的“quote\u 1”相乘,并将结果存储在“montant\u gain”中。
做那件事最好的要求是什么?

webghufk

webghufk1#

一种方法使用相关子查询:

  1. update table2 t2
  2. set montant_gain = (select t2.montant_pari * t1.quote_1
  3. from table1 t1
  4. where t1.id = t2.id_match -- I am guessing this is used to match rows
  5. );

相关问题