几个能够有帮助的sql文 好喜欢

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)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值