insert into table3(b,c,d)
select b,c,d from (
select b,c,d from table1 where ...
union
select b,c,d from table2 where ...
)
select b,c,d from (
select b,c,d from table1 where ...
union
select b,c,d from table2 where ...
)
insert into table3
select distinct b,c,d
from table1;insert into table1
select distinct b,c,d
from table2
where (b,c,d) not in (
select b,c,d from table1
);
commit;
这是什么原因
select b,c,max(d)
from
( select b,c,d from table1
union
select b,c,d from table2 )
group by b,c