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

查看:149
本文介绍了在MySQL中将一行移动到结果集的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在符合条件的情况下,我想在结果集的底部移动一行.

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

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

例如: SELECT * FROM TableName -SEND TO END OF RESULT SET- WHERE symbol = 'CASH'

结果集:

GOOG
VG
CASH


为澄清我的原始问题...

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


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:

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

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

这篇关于在MySQL中将一行移动到结果集的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆