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

(转)SQL 查找重复记录

表stuinfo,有三个字段recno(自增),stuid,stuname
建该表的Sql语句如下:
CREATE TABLE [StuInfo] (
[recno] [int] IDENTITY (1, 1) NOT NULL ,
[stuid] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[stuname] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
1.--查某一列(或多列)的重复值(只能查出重复记录的值,不能整个记录的信息)
--如:查找stuid,stuname重复的记录
select stuid,stuname from stuinfo
group by stuid,stuname
having(count(*))>1
2.--查某一列有重复值的记录(这种方法查出的是所有重复的记录,也就是说如果有两条记录重复的,就查出两条)
--如:查找stuid重复的记录
select * from stuinfo
where stuid in (
select stuid from stuinfo
group by stuid
having(count(*))>1
)
3.--查某一列有重复值的记录(只显示多余的记录,也就是说如果有三条记录重复的,就显示两条)
--这种方成绩的前提是:需有一个不重复的列,本例中的是recno
--如:查找stuid重复的记录
select * from stuinfo s1
where recno not in (
select max(recno) from stuinfo s2
where s1.stuid=s2.stuid
)
下面这个是查出所有重复记录的SQL语句:
方法1:  
  SQL>   Select   *   from   table_name   A   WHERE   ROWID   >   (  
            SELECT   min(rowid)   from   table_name   B  
            WHERE   A.key_values   =   B.key_values);  
   
  方法2:  
        SQL>   select   *   from   table_name   t1  
                  where     exists   (select   'x'   from   table_name&n


相关文档:

JAVA连接ACCESS,SQL Server,MySQL,Oracle

import java.sql.*;
/*
* JAVA连接ACCESS,SQL Server,MySQL,Oracle数据库
*
* */
public class JDBC {
  
public static void main(String[] args)throws Exception {
  
   Connection conn=null;
  
       //====连接ACCESS数据库 ......

[收拢] 用sqlite 执行标准 sql 语法

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. 执行sql语句
int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callbacksql 语法
, void *,  char **errmsg );
这就是执行一条 sql 语句的函数。
第1个参数不再说了,是前面open函数得到的指针。说了是关键数据结构。
第2个参数const char ......

恢复oracle中用pl sql误删除drop掉的表


查看回收站中表
select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recyclebin;
恢复表
SQL>flashback table test_drop to before drop;或
SQL>flashback table "BIN$b+XkkO1RS5K10uKo9BfmuA==$0" to before drop;
......

SQL操作全集

SQL操作全集
下列语句部分是Mssql语句,不可以在access中使用。
SQL分类:
DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
首先,简要介绍基础语句:
1、说明:创建数据库
CREATE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号