数据库共有5000多条数据,每30条插入一个时间(共有180个时间) 怎么写php或者mysql的语句?
数据库共有5000多条数据,每30条插入一天(共有180天) 怎么写php或者mysql的语句?
2013-07-04 09:00:00
2013-07-05 09:00:00
2013-07-06 09:00:00
2013-07-07 09:00:00
2013-07-08 09:00:00
2013-07-09 09:00:00
2013-07-10 09:00:00
2013-07-11 09:00:00
2013-07-12 09:00:00
2013-07-13 09:00:00
2013-07-14 09:00:00
2013-07-15 09:00:00
2013-07-16 09:00:00
2013-07-17 09:00:00
2013-07-18 09:00:00
2013-07-19 09:00:00
2013-07-20 09:00:00
2013-07-21 09:00:00
2013-07-22 09:00:00
2013-07-23 09:00:00
2013-07-24 09:00:00
2013-07-25 09:00:00
2013-07-26 09:00:00
2013-07-27 09:00:00
2013-07-28 09:00:00
2013-07-29 09:00:00
2013-07-30 09:00:00
2013-07-31 09:00:00
2013-08-01 09:00:00
2013-08-02 09:00:00
2013-08-03 09:00:00
2013-08-04 09:00:00
2013-08-05 09:00:00
2013-08-06 09:00:00
2013-08-07 09:00:00
2013-08-08 09:00:00
2013-08-09 09:00:00
2013-08-10 09:00:00
2013-08-11 09:00:00
2013-08-12 09:00:00
2013-08-13 09:00:00
2013-08-14 09:00:00
2013-08-15 09:00:00
2013-08-16 09:00:00
2013-08-17 09:00:00
2013-08-18 09:00:00
2013-08-19 09:00:00
2013-08-20 09:00:00
2013-08-21 09:00:00
2013-08-22 09:00:00
2013-08-23 09:00:00
2013-08-24 09:00:00
2013-08-25 09:00:00
2013-08-26 09:00:00
2013-08-27 09:00:00
2013-08-28 09:00:00
2013-08-29 09:00:00
2013-08-30 09:00:00
2013-08-31 09:00:00
2013-09-01 09:00:00
2013-09-02 09:00:00
2013-09-03 09:00:00
2013-09-04 09:00:00
2013-09-05 09:00:00
2013-09-06 09:00:00
2013-09-07 09:00:00
2013-09-08 09:00:00
2013-09-09 09:00:00
2013-09-10 09:00:00
2013-09-11 09:00:00
2013-09-12 09:00:00
2013-09-13 09:00:00
2013-09-14 09:00:00
2013-09-15 09:00:00
2013-09-16 09:00:00
2013-09-17 09:00:00
2013-09-18 09:00:00
2013-09-19 09:00:00
2013-09-20 09:00:00
2013-09-21 09:00:00
2013-09-22 09:00:00
2013-09-23 09:00:00
2013-09-24 09:00:00
2013-09-25 09:00:00
2013-09-26 09:00:00
2013-09-27 09:00:00
2013-09-28 09:00:00
2013-09-29 09:00:00
2013-09-30 09:00:00
2013-10-01 09:00:00
2013-10-02 09:00:00
2013-10-03 09:00:00
2013-10-04 09:00:00
2013-10-05 09:00:00
2013-10-06 09:00:00
2013-10-07 09:00:00
2013-10-08 09:00:00
2013-10-09 09:00:00
2013-10-10 09:00:00
2013-10-11 09:00:00
2013-10-12 09:00:00
2013-10-13 09:00:00
2013-10-14 09:00:00
2013-10-15 09:00:00
2013-10-16 09:00:00
2013-10-17 09:00:00
2013-10-18 09:00:00
2013-10-19 09:00:00
2013-10-20 09:00:00
2013-10-21 09:00:00
2013-10-22 09:00:00
2013-10-23 09:00:00
2013-10-24 09:00:00
2013-10-25 09:00:00
2013-10-26 09:00:00
2013-10-27 09:00:00
2013-10-28 09:00:00
2013-10-29 09:00:00
2013-10-30 09:00:00
2013-10-31 09:00:00
2013-11-01 09:00:00
2013-11-02 09:00:00
2013-11-03 09:00:00
2013-11-04 09:00:00
2013-11-05 09:00:00
2013-11-06 09:00:00
2013-11-07 09:00:00
2013-11-08 09:00:00
2013-11-09 09:00:00
2013-11-10 09:00:00
2013-11-11 09:00:00
2013-11-12 09:00:00
2013-11-13 09:00:00
2013-11-14 09:00:00
2013-11-15 09:00:00
2013-11-16 09:00:00
2013-11-17 09:00:00
2013-11-18 09:00:00
2013-11-19 09:00:00
2013-11-20 09:00:00
2013-11-21 09:00:00
2013-11-22 09:00:00
2013-11-23 09:00:00
2013-11-24 09:00:00
2013-11-25 09:00:00
2013-11-26 09:00:00
2013-11-27 09:00:00
2013-11-28 09:00:00
2013-11-29 09:00:00
2013-11-30 09:00:00
2013-12-01 09:00:00
2013-12-02 09:00:00
2013-12-03 09:00:00
2013-12-04 09:00:00
2013-12-05 09:00:00
2013-12-06 09:00:00
2013-12-07 09:00:00
2013-12-08 09:00:00
2013-12-09 09:00:00
2013-12-10 09:00:00
2013-12-11 09:00:00
2013-12-12 09:00:00
2013-12-13 09:00:00
2013-12-14 09:00:00
2013-12-15 09:00:00
2013-12-16 09:00:00
2013-12-17 09:00:00
2013-12-18 09:00:00
2013-12-19 09:00:00
2013-12-20 09:00:00
2013-12-21 09:00:00
2013-12-22 09:00:00
2013-12-23 09:00:00
2013-12-24 09:00:00
2013-12-25 09:00:00
2013-12-26 09:00:00
2013-12-27 09:00:00
2013-12-28 09:00:00
2013-12-29 09:00:00
2013-12-30 09:00:00
[解决办法]
举例伪代码:
$sql = "select * from tabname";
$result = mysql_query($sql);
$i = 0;
while($row = mysql_fetch_array($result)){
if ($i%30 == 0){
$data['ctime'] = $row['time'];
}
$data['name'] = $row['name'];
$m->add($data);
$i++;
}