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

MySQL重复记录 查询及删除

查询及删除重复记录的方法
(一)
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_status=0
begin
select @max = @max -1
set rowcount @max
delete from 表名 where 主字段 = @id
fetch cur_rows into @id,@max
end
close cur_ro


相关文档:

Mysql提权

(1)获取Mysql数据库的root用户密码和数据库用户名
(2)上传提权php木马,通过连接3389可以知道服务器是2003系统
(3)udf.dll对应操作系统
C:\Winnt\udf.dll    2000
C:\Windows\udf.dll 2003
(4)设置相应的路径后直接导出。
(5)执行以下命令
create function cmdshell returns string soname 'udf ......

Mysql LOAD DATA命令的相关事项

1.在WINDOW下,记录数据的文本文件必须不能以中文命名(命令行界面无法输入中文),且需保存在磁盘根目录下。
2.字段值之间必须要以LOAD DATA命令中指定的分隔符分隔,默认为TAB,否则不识别,造成该字段值为NULL。
3.值为空的字段,在文本文件里可以设为空,也可以设为\N.
4.WINDOW下,不加"LINES TERMINATED BY ' ......

Oracle移植到MySQL注意事项

  客户用的数据库是mysql,而研发好的产品支持oracle,为了让客户掏腰包,我们必须把数据库环境从oracle转向mysql。我们在转换的过程中碰到了下面一些问题,希望能给同样遭遇的同仁们一些借鉴。如果我们在最初的设计、编码过程中注意数据库的移植性,这种情况下可以完全不需要作额外工作。
  一、数据库环境从oracle转 ......

更改mysql数据库编码为GBK

刚刚安装完mysql后
从cmd中进入mysql数据库
命令行中输入:
mysql -uroot -p123
进入mysql数据库中
命令行中输入:
status;
查看当前数据库中的编码
如下:
--------------
mysql  Ver 14.12 Distrib 5.1.7-beta, for Win32 (ia32)
Connection id:       &nb ......

MySQL给用户名添密码的五种方法(转载)

1.通过修改MYSQL数据库中MYSQL库的USER表 
       就用普通的UPDATE、INSERT语句就可以 
use mysql 
update user set Password=password('newpassword') where User='root'; 
flush privileges; 
(这个亲自实验过,可以执行!)
2.在命令行中使用如下命令 
&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号