select * from conferenceReg A where (select count(id) from conferenceReg where A.id=id) >1
//数据倒入后察看是否存在数据冗余
(Sql server)select top n * from 表 order by newid()
(Access)Select top n * FROM 表 orDER BY Rnd(id)
(mysql)Select * From 表 order By rand() Limit n
//从一个表中随机地取出N 条不重複的数据
select name from syscolumns where id=object_id('T_name')
//返回表的字段名稱
select * into (new_table) from (old_table) where 1<>1
//新建一個與原表一樣的空的新表
SELECT name, id, xtype FROM dbo.sysobjects WHERE (xtype = 'u')
//sysobjects 簡單的?就是存放表名的地方
insert into conference_kkk
select id+1600000 as id ,
case type_code when 0 then 0 else type_code+1600000 end type_code,
type_kbn,title_name,
dateadd (s,id,getdate())date ,user_code,message,null
from conference_kkk
会議室システムのデータ改善します
ms sql:
select top 1 id as preid from table a where a.id < 9 order by a.id desc
union all
select top 1 id as nextid from table a where a.id > 9 order by a.id
oracle:
select id as preid from table a where a.id < 9 and rownum = 1 order by a.id desc
union all
select id as nextid from table a where a.id > 9 and rownum = 1 order by a.id
//抄袭蜗牛的 呵呵上一条记录和下一条记录的选择问题
Between//paoluo(一天到晚游泳的鱼)
取一张表上一条记录的上下记录和该条记录:
int aa=“”;
aa=x;
Select * From TEST Where ID Between IsNull((Select Max(ID) From TEST Where ID < aa), aa) And IsNull((Select Min(ID) From TEST Where ID > aa), aa)