`

查询重复或去重复字段记录

 
阅读更多
--查询不重复name的数据
select * from test where name not in(
           select name from test
                       group by name
                       having count(name)>1)
--查询重复name的数据
select * from test where name  in(
          select name from test
          group by name
          having count(name)>1)
--删除重复记录
Select distinct * into #Tmp from tableName
Drop table tableName
Select * into tableName from #Tmp
Drop table #Tmp

--将一个表记录追加到另外一个相同表
insert   into   表2(与表1相对应的字段列表)   select   *   from   表1

insert   into   表2   (Class_1,class_2,email_address,http,websit_name,grate,register_time) 
selct   col001,col002,col003,col004,col005,'普通用户',getdate()   from   表1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics