a表
id count
1 10
2 20
3 30b表
id count
1 20
2 5
3 10a表和b表象比较,如果b表的Count大于a表的Count,更新a表
更新后效果
a表
id count
1 20
2 20
3 30请问这条Sql 语句怎么写
id count
1 10
2 20
3 30b表
id count
1 20
2 5
3 10a表和b表象比较,如果b表的Count大于a表的Count,更新a表
更新后效果
a表
id count
1 20
2 20
3 30请问这条Sql 语句怎么写
select id,max(count) as 'count' from
(
select id,count from a
union
select id,count from b
)
group by id
select Max(c.count) from (select id,count from a union select id,count from b) c
where c.id = a.id from a