怎么样让数据只显示前5行啊,,用SQL语句写..

shanghendelei 2003-04-11 11:08:11
怎么样让数据只显示前5行啊,,用SQL语句写..
...全文
692 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2003-04-11
  • 打赏
  • 举报
回复
select top n * from table
n 是你要显示的行数,例如:显示前5行
select top 5 from table
zealberg 2003-04-11
  • 打赏
  • 举报
回复
:HawaiiLeo(罗马数字)
: select top 5 * from '表名' group by 排序字段

应该用Order By吧?

Select Top 5 * From TableName Order By theOrderField [DESC]



mjhnet 2003-04-11
  • 打赏
  • 举报
回复
TOP
newdongkui 2003-04-11
  • 打赏
  • 举报
回复
1. select top 5 * from table

2. set rowcount 5
select * from yourtable
HawaiiLeo 2003-04-11
  • 打赏
  • 举报
回复
select top 5 * from '表名' group by 排序字段
ourme 2003-04-11
  • 打赏
  • 举报
回复
select top 10 * from '表名'
ly840325 2003-04-11
  • 打赏
  • 举报
回复
select top 5 * from 表名 group by 排序方式
shanghendelei 2003-04-11
  • 打赏
  • 举报
回复
帮我看看这个看有什么问题..总是出现"请核对您的用户名和密码!"
<%@ Language=VBScript %>
<!--#include file=conn1.asp -->
<%
name=session("name")
psw=session("psw")

name=replace(name,"'","''")
psw=replace(psw,"'","''")

set rs5=server.CreateObject ("ADODB.RecordSet")
sql5="select * from user where 姓名='" & name & "' and password='" & psw & "'"
rs5.Open sql5,conn,1,3

if not rs5.EOF then
name=rs5.Fields ("姓名")
psw=rs5.Fields ("password")
' session("tjrname")=rs.Fields ("姓名")
Response.Redirect "chaxun.asp"
else
Response.Write "请核对您的用户名和密码!"
Response.End
end if
%>
shanghendelei 2003-04-11
  • 打赏
  • 举报
回复
select * from gongqiou where 型号 like '%" & session("xinghao") & "%' order by id desc"
我用这个时..无论给"xinghao"什么值..都是查出所有内容
akeyta 2003-04-11
  • 打赏
  • 举报
回复
像Oracle, MySQL数据库不支持top n的。

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧