mysql 使用insert into ....ON DUPLICATE key update

2021/7/9 19:09:57

本文主要是介绍mysql 使用insert into ....ON DUPLICATE key update,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

$tableName = "domain_5min_result_{$data}";
//原生写法
$data = M()->execute("insert into channel_stat.domain_5min_result_20201023 (`user_id`,`cdn_type_id`,`down_domain_id`,`open_supplier_id`,`time_stamp`,`all_down_size`,`flow`) values(0,3,0,1,1597247700,7500,7600) ON DUPLICATE key update flow=values(flow)");
$field = "user_id,cdn_type_id,down_domain_id,open_supplier_id,time_stamp,all_down_size,flow";
$updateField = 'all_down_size,flow';
$bandWidthData[0]['flow'] ="12232313213";
//thinkphp写法
$data =D('Stat/Domain5MinResult')->add($bandWidthData[0], [
    'table' =>'domain_5min_result_20201008' ,
    'field' => $field
], $updateField);

 



这篇关于mysql 使用insert into ....ON DUPLICATE key update的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程