# 修改表结构
alter table c_gh drop column `__action`;
alter table c_gh add column `__action` STRING NULL DEFAULT 'insert' COMMENT '对应的操作';
1
2
2
# 内存表关联
select A.*
from sequelize_test as A
inner join (
values ('有个人0' as name, 12 as age),
('有个人1', 24),
('bbb', 12)
) as B
on A.name = B.name and A.age = B.age
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 关联更新
update
sequelize_test
set sequelize_test.age = B.age
from sequelize_test inner join (
values ('有个人0' as name, 12 as age),
('有个人', 24),
('bbb', 12)
) as B
on sequelize_test.name = B.name
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# 数据去重处理
delete from q_produce
where id in (
select a.id,a.pro_line,a.schedule_id
from q_produce a left join
(select c.pro_line,c.schedule_id, max(c.id) as bid
from q_produce c
where org_id = 576517414859776
group by pro_line, schedule_id
having count(1)>1
) b
on a.id < b.bid
where a.pro_line=b.pro_line
and a.schedule_id = b.schedule_id
and a.id < b.bid )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15