
需要准备的材料分别是:电脑、php编辑器、浏览器。
1、首先打开mysql查询器,例如以c1表add_time字段为例。
2、其次,打开php编辑器,新建php文件,例如:index.php。
3、在index.php中,输入代码:$date = date('Y-m-d')$conn = new mysqli('localhost', 'root', '', 'test')$sql = 'update c1 set add_time="' . $date . '"'$conn->query($sql)。
4、浏览器运行index.php页面,之后在mysql查询器查看,发现时间已经被存进add_time了。
提供一个思路:就是将所有比较的时间,都转换为时间戳再比较,select * from table where unix_timestamp(`atime`) betweeen unix_timestamp('2017-08-22 10:00:00') and unix_timestamp('2017-08-22 12:00:00')
两种方式 :1、可以直接用SQL 里的函数 sum()
如:"select sum(字段) as num from tab "//sum 取该字段所有列的总和
2、用PHP函数 sum($array) ; //取数组中值的总和
当然 字段必须是int型的
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)