社区
C#
帖子详情
select top 5 * from table order by (id) desc
chenli133
2006-04-02 12:05:25
这里的关键字top是不是适用于任何数据库?请大家赐教
...全文
92
4
打赏
收藏
select top 5 * from table order by (id) desc
这里的关键字top是不是适用于任何数据库?请大家赐教
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ice_frank
2006-04-02
打赏
举报
回复
不是的,不过大部分数据库都支持
wolaile27
2006-04-02
打赏
举报
回复
不是,SQL SERVER 是支持的。
dinons
2006-04-02
打赏
举报
回复
不是所有的都支持,SQL SERVER 是支持的。
李洪喜
2006-04-02
打赏
举报
回复
不是的。有数据库不支持的。不过如果是使用SQL的数据库,应该是都支持吧。
MySQL不能用
Select
top 1 * from...这样的语句
select
top 1 * from [
table
name]
order
by
ID
des
c 报错
SELECT
top 1 * FROM version_manage where title ='mes'
order
by version
des
c > 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right.
9.排序查询(
select
from where
order
by(asc|
des
c))
进阶三:排序查询 引入:
SELECT
* FROM 表名; /* 语法:
select
* from
table
where 筛选条件
order
by 排序列表 asc|
des
c(默认升序) 支持多个字段,单个字段,表达式,函数,别名
order
by一般放在最后, limit子句除外 */ # 案例: 查询员工信息从薪水高到低显示 #
select
* from
table
order
by salary
des
c
SELECT
* FROM employees ORDE
sql 查询最大非主键
ID
方法
方法1:
select
top 1 * from
table
order
by
id
des
c 方法2:
select
MAX(
id
) from tb_user
ORDER
BY
id
des
c 方法3:
select
title from message where
id
=(
select
max(
id
)from message)
select
title from
SQL 语句从表中选取前5行,后5行的记录,以及%用法
--前5行
select
top 5 * from
table
--后5行
select
top 5 * from
table
order
by
id
des
c 其中
des
c 表示降序排列 asc 表示升序
select
* from tb_shop
id
order
by
id
des
c limit 0,1
order
by
id
des
c是按
id
进行降序排列limit 0,1 是只取记录中的第一条.所以这条语句只能得到一条记录如想取前10条则 limit 0,10或limit 10如想取第10至20条则 limit 10,20
C#
110,502
社区成员
642,567
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章