mysql和并两张表并且去掉重复数据

直接上语句ym_area_code_copy1是表1ym_area_code_copy是表2

 

insert      into      ym_area_code_copy1                                                                                                                                              (area_id,first_letter,area_name,parent_id,area_code,full_name,area_type,state,create_time,update_time)
selecct area_id,first_letter,area_name,parent_id,area_code,full_name,area_type,state,create_time,update_time    from        ym_area_code 
where not EXISTS(select * from ym_area_code_copy1 where ym_area_code_copy1.area_code=ym_area_code.area_code)

你可能感兴趣的:(mysql)