如何更改字段';在mysql中使用select insert时的s值

如何更改字段';在mysql中使用select insert时的s值,mysql,sql,Mysql,Sql,sql语句是 INSERT INTO t_source_type_transfer(logdate,time, Host, CountryCode, RegionCode,City, SourceIP, Hits, cdn_id, CityName ,type) select b.logdate,b.time,b.Host,b.CountryCode, b.RegionCode,b.City, b.SourceIP, b.Hits, b.cdn_id, b.CityName ,b.typ

sql语句是

INSERT INTO t_source_type_transfer(logdate,time, Host, CountryCode, RegionCode,City, SourceIP, Hits, cdn_id, CityName ,type) 
   select b.logdate,b.time,b.Host,b.CountryCode, b.RegionCode,b.City, b.SourceIP, b.Hits, b.cdn_id, b.CityName ,b.type  
   from t_source_type as b 
ON DUPLICATE KEY UPDATE Hits=t_source_type.Hits+b.Hits;
t\u source\u type
中的时间字段为14:35:21

使用该语句时,如何将其更改为14:35:00


谢谢

我认为使用
maketime()
是一种更清晰的方法,可以四舍五入到最近的一分钟:

INSERT INTO t_source_type_transfer(logdate, time, Host, CountryCode, RegionCode, City, SourceIP, Hits, cdn_id, CityName, type) 
   select b.logdate,
          maketime(hour(b.time), minute(b.time), 0),
          b.Host, b.CountryCode, b.RegionCode, b.City, b.SourceIP, b.Hits, b.cdn_id, b.CityName ,b.type  
   from t_source_type b 
ON DUPLICATE KEY UPDATE Hits=t_source_type.Hits+b.Hits;

这方面的小变化也适用于许多分钟的倍数,例如5分钟或30分钟。

因此,您需要一种方法,在将其插入
t\u source\u type\u transfer.time
之前,截断
b.time
中的秒数。控制更改的规则是什么?您想减去21秒,还是将时间四舍五入到最接近的分钟、5分钟等。?你想要什么?是的,就像@underline\u d说的,我想要一种在将b.time插入到t\u source\u type\u传输之前截断秒数的方法。time@underscore_d谢谢,看起来很管用!太好了,如果它回答了你的问题,请把这个标记为那个的副本。