博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql导数据库用到的语句
阅读量:6160 次
发布时间:2019-06-21

本文共 1251 字,大约阅读时间需要 4 分钟。

将字段格式为2013-08-09 13:22:55转换为时间戳

UPDATE `AttendClass` SET `regdate` = unix_timestamp(regDate2) WHERE `rowid` = 118280;

 

将字段name前面添加一个字符x

update aa set name=concat('x',name)

 

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)

 

转载地址:http://ghhfa.baihongyu.com/

你可能感兴趣的文章
也问腾讯:你把用户放在什么位置?
查看>>
CSS Sprites 样式生成工具(bg2css)
查看>>
[转]如何重构代码--重构计划
查看>>
类中如何对list泛型做访问器??
查看>>
C++解析XML--使用CMarkup类解析XML
查看>>
P2P应用层组播
查看>>
Sharepoint学习笔记—修改SharePoint的Timeouts (Execution Timeout)
查看>>
CSS引入的方式有哪些? link和@import的区别?
查看>>
Redis 介绍2——常见基本类型
查看>>
asp.net开发mysql注意事项
查看>>
(转)Cortex-M3 (NXP LPC1788)之EEPROM存储器
查看>>
ubuntu set defult jdk
查看>>
[译]ECMAScript.next:TC39 2012年9月会议总结
查看>>
【Xcode】编辑与调试
查看>>
用tar和split将文件分包压缩
查看>>
[BTS] Could not find stored procedure 'mp_sap_check_tid'
查看>>
PLSQL DBMS_DDL.ALTER_COMPILE
查看>>
Activity生命周期
查看>>
高仿UC浏览器弹出菜单效果
查看>>
Ubuntu忘记密码,进不了系统的解决方法
查看>>