社区
应用实例
帖子详情
select * from table order by id=1,id=3 desc
decimal_cn
2006-06-14 09:28:06
select * from table order by id=1,id=3 desc
在access中可以正常运行,在sql中就不能得到正确结果,请高人指点
...全文
200
6
打赏
收藏
select * from table order by id=1,id=3 desc
select * from table order by id=1,id=3 desc 在access中可以正常运行,在sql中就不能得到正确结果,请高人指点
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
云中客
2006-06-14
打赏
举报
回复
select * from [table] where id=1 and id=3 order by id desc
楼主,还是把你的问题表达清楚些
yown
2006-06-14
打赏
举报
回复
select * from table order by id=1,id=3 desc
==>
select * from table where id=1
union all
select * from table where id=3 order by id desc
union all
select * from table where id not in(1,3)
xeqtr1982
2006-06-14
打赏
举报
回复
declare @t table(id int)
insert into @t select 1
insert into @t select 2
insert into @t select 3
insert into @t select 4
insert into @t select 5
insert into @t select 6
select * from @t order by case id when 1 then (select max(id)+1 from @t) when 3 then 0 else id end desc
--去试了一下,不知道是不是这种效果
billpu
2006-06-14
打赏
举报
回复
是不是如果id=1 就把1放在第一行 然后如果id=3就把3放最后一行?
xeqtr1982
2006-06-14
打赏
举报
回复
请教楼主这句话在access中的效果。access不太熟
friendlyFour
2006-06-14
打赏
举报
回复
select * from [table]
where id=1 or id=3
order by id desc
MySQL
ORDER
BY排序一篇就够了
本文详细介绍了MySQL
ORDER
BY的静态与动态排序原理,通过实例演示了单字段和多字段排序,以及如何结合CASE和IF实现动态条件下的排序。重点讲解了多字段排序中的分组效应和
ORDER
BY的执行顺序特点。
SQL
ORDER
BY 排序详解:ASC、
DES
C、多个字段排序技巧
本文详细介绍了 SQL 中
ORDER
BY 的基本语法与使用方法,包括单字段排序、多字段排序、升序(ASC)、降序(
DES
C)以及按别名和随机排序等实用技巧。通过实例展示了如何根据实际需求灵活运用排序功能。
mysql
order
by 多个字段 索引_mysql 索引优化
order
by 语句
本文介绍了MySQL中索引的创建方法,包括ASC和
DES
C排序,并详细解释了如何利用索引优化
ORDER
BY和GROUP BY语句,提升查询效率。
2.18 sql排序查询(
ORDER
BY、ASC、
DES
C)
本文系统讲解SQL中
ORDER
BY子句的使用方法,涵盖单字段升序(ASC)、降序(
DES
C)排序,多字段联合排序规则,基于表达式及列别名的动态排序,以及与WHERE、LIMIT配合实现TOP N分析。结合电商场景(如销量榜、高价值用户排行、最新订单优先等),强调常见陷阱(如NULL处理、字符串数字误排序、别名作用域)和性能优化建议(索引设计、避免filesort)。适用于MySQL/Oracle等关系型数据库。
MySql——查询语句
SELECT
FROM
本文详细介绍了SQL的基本操作,包括
SELECT
、WHERE、GROUP BY和
ORDER
BY语句的使用。并通过两个实战项目,查找重复电子邮箱和筛选大国,加深了对SQL查询的理解。
应用实例
27,581
社区成员
68,548
社区内容
发帖
与我相关
我的任务
应用实例
MS-SQL Server 应用实例
复制链接
扫一扫
分享
社区描述
MS-SQL Server 应用实例
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章