mySql往一个表中增加数据,如果已经有就更新,没有就插入数据:
replace into unitoll_total(ListNO,StarTime,EndTime,OwnerCode,Gross,ICType,SquadDate,ID)
select m.ListNO, m.StarTime,m.EndTime, m.OwnerCode, m.Gross, m.ICType, m.SquadDate, m.ID
from (
select t.ListNO, t.SquadDate as StarTime, t.SquadDate as EndTime,
t.OwnerCode, sum(t.toll) as Gross, t.ICType, t.SquadDate,
ifnull((select t1.ID from unitoll_total t1
where t1.SquadDate=t.SquadDate and t.ICType=t1.ICType),UUID()) as ID
from unitoll_detail t
where t.SquadDate="20150928T000000"
group by t.ICType
order by t.SquadDate desc
) m;mySql往一个表中增加数据,如果已经有就更新,没有就插入数据
最新推荐文章于 2024-07-06 19:19:46 发布
本文详细介绍了如何使用mySql进行数据操作,包括增加、更新和插入数据的方法,通过SQL查询实现数据整合。
2119

被折叠的 条评论
为什么被折叠?



