易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL重复记录查询

1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from people
where peopleId in (select   peopleId  from   people  group  by   peopleId  having  count(peopleId) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
delete from people
where peopleId  in (select   peopleId  from people  group  by   peopleId   having  count(peopleId) > 1)
and rowid not in (select min(rowid) from   people  group by peopleId  having count(peopleId )>1)
3、查找表中多余的重复记录(多个字段)
select * from vitae a
where (a.peopleId,a.seq) in   (select peopleId,seq from vitae group by peopleId,seq  having count(*) > 1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录
delete from vitae a
where (a.peopleId,a.seq) in   (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录
select * from vitae a
where (a.peopleId,a.seq) in   (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
(二)
比方说
在A表中存在一个字段“name”,
而且不同记录之间的“name”值有可能会相同,
现在就是需要查询出在该表中的各记录之间,“name”值存在重复的项;
Select Name,Count(*) from A Group By Name Having Count(*) > 1
如果还查性别也相同大则如下:
Select Name,sex,Count(*) from A Group By Name,sex Having Count(*) > 1
(三)
方法一
declare @max integer,@id integer
declare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) >; 1
open cur_rows
fetch cur_rows into @id,@max
while @@fetch_s


相关文档:

在PHP中全面阻止SQL注入式攻击之三

一、 建立一个安全抽象层
  我们并不建议你手工地把前面介绍的技术应用于每一个用户输入的实例中,而是强烈推荐你为此创建一个抽象层。一个简单的抽象是把你的校验方案加入到一个函数中,并且针对用户输入的每一项调用这个函数。当然,我们还可以创建一种更复杂的更高一级的抽象-把一个安全的查询封装到一个类中,从而应 ......

SQL server不能远程连接

这段时间碰到一个很奇怪的问题:SQL server不能远程连接。命名管道和TCP/IP协议都已启用,防火墙也关闭了等等,但就是不能远程连接数据库。终于找到原因了,当输入数据库服务器实例名时应:\,, 平常一般不用附加端口号的。 ......

关于时间段的SQL(Orcale、SQL Server)查询

一、Orcale 时的查询
String hql = "from SmsTemplate t where 1=1 ";
 if (model != null && !"".equals(model.getEndTimes())&& null!=model.getEndTimes() ) {
   SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd"); //格式化当前系统日期
   Date ......

批处理安装SQL SERVER 脚本文件

createdb.bat文件
@echo off
echo ╬ ╱◥███◣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
echo ╬ ︱田︱田 田 ︱          ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号