将一行移动到MySQL中结果集的末尾(move one row to the end of a result set in MySQL)

编程入门 行业动态 更新时间:2024-10-07 05:19:47
将一行移动到MySQL中结果集的末尾(move one row to the end of a result set in MySQL)

在给定匹配条件的情况下,我想将行移动到结果集的底部。

数据库

+-------+------------+ |Symbol | Percentage | |-------|------------| |VG | 20 | |-------|------------| |CASH | 20 | |-------|------------| |GOOG | 60 | +-------+------------+

澄清我原来的问题......

我需要为ORDER BY语句编写一个异常。 将查询放入普通英语 - SELECT整行,按时间戳排序,除非符号为“CASH”

I would like to move a row to the bottom of the result set given a matched condition.

Database

+-------+------------+ |Symbol | Percentage | |-------|------------| |VG | 20 | |-------|------------| |CASH | 20 | |-------|------------| |GOOG | 60 | +-------+------------+

To clarify my original question...

I need to write an exception for an ORDER BY statement. To put the query into plain english - SELECT an entire row, ordering by a timestamp, except if the symbol is "CASH"

最满意答案

要更改结果集中行的顺序,您应该使用ORDER BY:

SELECT * FROM TableName ORDER BY symbol = 'CASH', timestamp

To change the order of the rows in a result set you should use ORDER BY:

SELECT * FROM TableName ORDER BY symbol = 'CASH', timestamp

更多推荐

本文发布于:2023-08-04 02:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408602.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:末尾   move   MySQL   set   result

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!