通过乘法和四舍五入更新列值

时间:2015-07-19 05:56:51

标签: php sql codeigniter

我希望将我的数据库列("。$ subject_column。" _theory )乘以10/7( 我的主题总数是70,我想将其转换为100以找到成绩。) 在乘法之后,结果必须四舍五入

  <paper-drawer-panel>
  <paper-header-panel drawer>
    <paper-toolbar>
      <div>Drawer</div>
    </paper-toolbar>
    <paper-menu selected="{{_selected}}">
      <paper-item>Item 1</paper-item>
    </paper-menu>
  </paper-header-panel>
  <paper-header-panel mode="standard" main>
    <paper-toolbar>
      <h1>[[_selected]]</h1>
    </paper-toolbar>
    <neon-animated-pages selected="{{_selected}}">
      <paper-button raised on-tap="showDialog">Show Dialog</paper-button>
      <div>Div</div>
    </neon-animated-pages>
  </paper-header-panel>
</paper-drawer-panel>
<my-greeting id="dialog"></my-greeting>

1 个答案:

答案 0 :(得分:1)

$update_subject_statement4 = "UPDATE ".$track_table_name."

SET `".$subject_column."` = ROUND(IF(`".$subject_column."_theory`='ab',0,`".$subject_column."_theory`) * 7 / 10) 
WHERE
evaluation_division="."'$eval_div' 
AND evaluation_config_id = ".$config_id." 
AND stream_index = ".$stream_index;   

$additional_sum_update_query = $this->db->query($update_subject_statement4);

第一名我们multiplied您的价值 7/10

IF(".$subject_column."_theory ='ab',0,".$subject_column."_theory * 7/10

第二名我们rounded

ROUND( IF(".$subject_column."_theory ='ab',0,".$subject_column."_theory)* 7/10