http://www.hanyu123.cn/html/c61/6790.html 一.查某一列(或多列)的重复值.(只可以查出重复记录的值,不能查出整个记录的信息) 例如:查找stuid,stuname重复的记录: select stuid,stuname from stuinfo group by stuid,stuname having(count(*))>1 二.查某一列有重复值的记录.(此方法查出的是所有重复的记录,如果有两条记录重复的,就查出两条) 例如:查找stuid重复的记录:…
oracle 中随机取一条记录的两种方法 V_COUNT INT:=0; V_NUM INT :=0; 1:TBL_MYTABLE 表中要有一个值连续且唯一的列FID BEGIN SELECT COUNT(*) INTO V_COUNT FROM TBL_MYTABLE; SELECT TRUNC(DBMS_RADOM.VALUE(1,V_COUNT+1)) INTO V_NUM FROM DUAL; SELECT * FROM TBL_MYTABLE T WHERE T.FID=V_NUM;…
如果我们创建了(area, age,salary)的复合索引,那么其实相当于创建了:(area,age,salary),(area,age).(area)三个索引,这被称为最佳左前缀特性.因此我们在创建复合索引时应该将最常用作限制条件的列放在最左边,依次递减.例:select * from test where area='11' select * from test where area='11' and age=1 select * from test where area='11' and…
1. 使用静态工厂方法创建Bean,用到一个工厂类 例子:一个Car类,有brand和price属性. package com.guigu.spring.factory; public class Car { private String brand; private double price; public Car(){ } public Car(String brand,double price){ this.brand=brand; this.price=price; } public S…
比较实用的debug方法:具体参考地址已经记不清了,这里重写成类方便调用 /** * @author logonmy@126.com * @Date: 13-7-23 * @desc example to count application run time */ class Interval{ var $start; public function getTrueTime() { list($sec,$unix) = explode(' ',microtime()); return (…
方案一:使用ignore关键字 如果是用主键primary或者唯一索引unique区分了记录的唯一性,避免重复插入记录可以使用: insert ignore into table_name(email,phone,user_id) values('test9@163.com','99999','9999'), 这样当有重复记录就会忽略,执行后返回数字0,还有个应用就是复制表,避免重复记录: insert ignore into table(name) select name from tab…
1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select * from peoplewhere peopleId in (select peopleId from people group by peopleId having count (peopleId) > 1) 2.删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录delete from people where peopleId in (se…
http://blog.csdn.net/smahorse/article/details/8156483 --SQL Server 查询表的记录数 --one: 使用系统表. SELECT object_name (i.id) TableName, rows as RowCnt FROM sysindexes i INNER JOIN sysObjects o ON (o.id = i.id AND o.xType = 'U ') WHERE indid < 2 ORDER BY TableN…
--SQL Server 查询表的记录数 --one: 使用系统表. SELECT object_name (i.id) TableName, rows as RowCnt FROM sysindexes i INNER JOIN sysObjects o ON (o.id = i.id AND o.xType = 'U ') ORDER BY TableName --****************** --two: 使用未公开的过程 "sp_MSforeachtable " ),…
--创建测试表 )); ,'); ,'); ,'); ,'); ,'); ,'); commit; select * from test; --查询相同记录 ); select id,name from test a where rowid > (select min(rowid) from test b where a.id = b.id and a.name = b.name); select id,name from test a where rowid <> (select ma…