A表中有个字段 A_NAME 其中有单位名称100个(可能有重复名称)
B表中有个字段 B_NAME 其中有单位名称30个(没有重复名称)
要求:
1 比对A_NAME & B_NAME 将A_NAME 没有的插入B_NAME;
2 如果A_NAME有重复的 在B_count中加数据A_NAME
张三
李四
王二麻
张三
B_NAME
李四
王二麻 处理后是B表是======> B_NAME B_count
李四
王二麻
张三 2
B表中有个字段 B_NAME 其中有单位名称30个(没有重复名称)
要求:
1 比对A_NAME & B_NAME 将A_NAME 没有的插入B_NAME;
2 如果A_NAME有重复的 在B_count中加数据A_NAME
张三
李四
王二麻
张三
B_NAME
李四
王二麻 处理后是B表是======> B_NAME B_count
李四
王二麻
张三 2
select A_NAME ,count(*)
from A
group by A_NAME
where A_NAME not in (select B_NAME from B);
create or replace procedure process1
is
cursor cur_title is select tid,title from t_maps_hot
where title not in (select com_name from t_yp_thread);
m_tid varchar(200);
m_title varchar(200);
m_content varchar(200);
hot_id varchar(200);
num_id number;
begin
open cur_user;
loop
fetch cur_user into m_tid,m_title;
exit when cur_user%NOTFOUND;
begin
m_content:='|';
select count(*) into num_id from t_yp_thread where com_name=m_title;
if num_id=0 then
m_content:=m_content+m_tid+'|';
else
begin
select maps_hot_id into hot_id from t_yp_thread where com_name=m_title;
m_content:=hot_id+'|'+m_tid+'|';
end;
end if;
insert into t_yp_thread(maps_hot_id,com_name,im) values(m_content,m_title,m_title);
commit;
end;
end loop;
close cur_user;
end;
/