使用 ORDER BY 实现小于日期时间

问题描述 投票:0回答:1
继续我之前的问题。

这里

使用 ORDER BY 将某行移动到所有行的顶部之后

SELECT * FROM comments ORDER BY comment <> 'my comment', id;
如果我想要 

other comment

 从小于 id = 5 的示例开始,该怎么办?

id comment other comment 149 my comment other comment 148 my comment other comment 147 my comment my comment => 4 other comment -- start from less than id = 5 other comment 3 other comment my comment 2 other comment my comment 1 other comment
    
sql postgresql sql-order-by
1个回答
0
投票
应翻译为:

SELECT * FROM comments WHERE (id < 5 or comment = 'my comment') ORDER BY comment <> 'my comment', id DESC
    
© www.soinside.com 2019 - 2024. All rights reserved.