tempad
Readygo技术搜索引擎 >>项目管理 >> 如何得到Select结果集中某一行中的数据???

如何得到Select结果集中某一行中的数据???

Readygo技术搜索引擎 网络搜索 efish 2008-1-17 4:58:19

如何得到Select结果集中某一行中的数据???

楼主gjpfly(魔术师)2002-11-07 12:47:01 在 MS-SQL Server / 疑难问题 提问

For   sample,    
  select   *   from   item    
  would   produce   100   rows.   but   I   want   to   get   the   result   of   row   8.   I   know   it   can   be   done   by   cursor   or   looping.   but   there   is   any   direct   method   ?  
   
  what   I   thought   is   like:  
  select   *   from   item   where   rowcount   =   8.    
   
  but   sybase   10.9   not   support   rowcount. 问题点数:20、回复次数:9Top

1 楼chump(木人)回复于 2002-11-07 12:55:29 得分 0

好象没有办法!oracle中有rownum,SQL中没有啊!Top

2 楼Drate(小虫(好好学习,天天向上))回复于 2002-11-07 12:57:45 得分 0

除非在编程语言中,将结果集选择到客户端,然后再用定位函数,得到这条记录Top

3 楼sky_blue(蓝天2006)回复于 2002-11-07 12:59:14 得分 0

select   identity(int,1,1)x,*   into   #tmp   from   item    
  select   *   from   #tmp   where   x=8  
   
  没办法,只能这么做,SQLSERVER中不支持rownumTop

4 楼chenun(chenun)回复于 2002-11-07 14:20:25 得分 0

select   top   n   *   from   item    
  --   n   为行数Top

5 楼lxinjun(lxj)回复于 2002-11-07 14:55:00 得分 10

ID为主见  
  SELECT   TOP   1   FROM   (SELECT   TOP   N   FROM   TABLE   ORDER   BY   ID   DESC)  
  Top

6 楼LaoZheng(阿明)回复于 2002-11-07 15:42:45 得分 0

upTop

7 楼mylovexs(不了塵)回复于 2002-11-07 16:31:27 得分 0

使用游標Top

8 楼enewren(*乡下的程序员*)回复于 2002-11-07 20:22:12 得分 0

select   top   n   *   from   tablename  
  这是得到前n   条记录呀!!我今天才用过的,如何得到第n条记录????Top

9 楼jery_lee(U2-G2000)回复于 2002-11-07 21:03:32 得分 10

Declare   cur   Cursor  
  Declare   @col1   integer  
                  @col2   integer  
  for   Select   col1,col2  
  From   Tablename  
  Open   cur  
  Fetch   cur   ABSOLUTE   n   into   @col1,@col2Top

责任编辑: efish 参与评论 查找更多:
相关文章
请教:怎样在eVC 4.0中使用ActiveMovie? 请教:怎样在eVC 4.0中使用ActiveMovie?
为什么用SetDlgItemText 无法更改Static Text中的内… 为什么用SetDlgItemText 无法更改Static Text中的内容。
关于TreeView中节点拖放问题 关于TreeView中节点拖放问题
OEM版Win XP被攻陷纪实 OEM版Win XP被攻陷纪实
安装2000Server时的问题,急!急!急! 安装2000Server时的问题,急!急!急!
安全的问题?大家帮忙 安全的问题?大家帮忙
linux下的浏览器哪一款最好? linux下的浏览器哪一款最好?
关于ExitwindowsEx函数问题,请教。 关于ExitwindowsEx函数问题,请教。
请教大家一个问题。。。呵呵 请教大家一个问题。。。呵呵
请问如何使用VB代码写一段删除硬回车符的程序! 请问如何使用VB代码写一段删除硬回车符的程序!
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn

分类导航
Readygo技术搜索引擎