使用insert into on duplicate key update
sql语句为
insert into tableA(`key1`,`key2`,`F1`,`F2`...) values ('A','AA',5,5,...) on duplicate key update `F1`=`F1`+values(`F1`),`F2`=`F2`+values(`F2`)....SQL code?1
2
3
select uid,names,addtime from tb1 where ...
union --all 去掉all可以去重复
select uid,names,addtime from tb2 where ...
/**
这个语句里字段的别名都是取第一个查询的字段名或其别名作为查询结果集的字段名的
*/
select uid,names,addtime from tb1 where ...
union --all 去掉all可以去重复
select uid,names,addtime from tb2 where ...
/*上边查询结果集的字段名是uid,names,addtime*/
select uid,names,addtime from tb1 where ...
union --all 去掉all可以去重复
select uid,titles,addtime from tb2 where ...
/*上边查询结果集的字段名是uid,names,addtime*/
select uid,titles,addtime from tb1 where ...
union --all 去掉all可以去重复
select uid,names,addtime from tb2 where ...
/*上边查询结果集的字段名是uid,titles,addtime*/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)