读者数据库里面删除重复数据

delete from Readers where ID in
 (
 select dz.ID from Readers dz
 left join XX04 bj on dz.BJBH=bj.BJBH
 left join JX01 zy on bj.ZYBH=zy.ZYBH
  where dz.SFZH in 
 (select SFZH from Readers group by SFZH having count(SFZH) > 1)
 and zy.CCDM='4'
 )
/******查找形如'1234-5678'数据*****/
select * from  Search_Encod where len(SJ)=9 and CHARINDEX('-',SJ)=5 AND  len(Replace(SJ,'-',''))=len(SJ)-1  

 两张表要修改其中一个表某个字段赋值给另一个表的相应字段

比如Journal_Library(馆藏期刊典藏库)Library_Collection(馆藏书目库),两个表都有SSH(索书号)这个字段,
并且Journal_Library表的ZJM字段和Library_Collection表的ID字段成对应关系,
现在需要把Library_Collection表的索书号赋值给Journal_Library表的索书号字段,SQL语句如下 update Journal_Library
set SSH=smk.SSH from Library_Collection as smk where (Journal_Library.SSH='' or Journal_Library.SSH is null) and Journal_Library.ZJM=smk.ID

 

posted @ 2017-01-08 12:54  我的名称很霸气  阅读(150)  评论(0编辑  收藏  举报