如题:
在A表中
col1 col2 col3 col4 col5 col6 col7 col8 col9 列
1 a c d e f g h j
2 b r u u i o p p
3 q w d f e t t y
4 w y u i o y u p
5 l k j h g b m n这样一个表,将整个表的col2 col3 col4 col5 col6 col7 col8 col9 导入到B表,B表中col2 col3 col4 col5 字段为唯一索引,不能重复问题,怎么将A表中col2 col3 col4 col5 重复的去掉,只留住一条,导入时不出错
在A表中
col1 col2 col3 col4 col5 col6 col7 col8 col9 列
1 a c d e f g h j
2 b r u u i o p p
3 q w d f e t t y
4 w y u i o y u p
5 l k j h g b m n这样一个表,将整个表的col2 col3 col4 col5 col6 col7 col8 col9 导入到B表,B表中col2 col3 col4 col5 字段为唯一索引,不能重复问题,怎么将A表中col2 col3 col4 col5 重复的去掉,只留住一条,导入时不出错
t
from
a t
where
exists(select 1 from a where col2=t.clo2 and col3=t.col3 and col4=t.col4 and col5=t.col5 and col1<>t.col1)
select col2 col3 col4 col5 col6 col7 col8 col9 from ta a
where not exists ( select 1 from ta where col2=a.col2 and id>a.id)
and not exists ( select 1 from ta where col2=a.col2 and id>a.id)
and not exists ( select 1 from ta where col3=a.col3 and id>a.id)
and not exists ( select 1 from ta where col4=a.col4 and id>a.id)
and not exists ( select 1 from ta where col5=a.col5 and id>a.id)
delete
t
from
a t??
col1 col2 col3 col4 col5 col6 col7 col8 col9 列
9个列,导到B表的时候要确保col4 手机号码这一列唯一的,不能有重复