当前位置:网站首页>MySQL is required to sort in ascending order greater than or equal to the current time, and then in descending order less than the current time
MySQL is required to sort in ascending order greater than or equal to the current time, and then in descending order less than the current time
2022-06-11 02:46:00 【Diligent learning is like the seedling of spring】
Now there is a news table , There is a time field in the table .
I want one now select The data we found out , In sorting, you first sort by ascending order greater than or equal to the current time , Then sort in descending order less than the current time .
For example , For example, today is 4 month 7 Number . We have... In our database 4 month 5 Number ,4 month 6 Number ,4 month 7 And 4 month 8 News on
So the order I found out is -->4 month 7 Number ,4 month 8 Number ,4 month 6 Number ,4 month 5 Number .
The problem is basically the same :http://bbs.csdn.net/topics/380215463
But this post says SQL Server, After a look, the sentence can't be in MySQL In the use .
use union all Should be able to complete , But if you want to page , need limit Words ,union all Can't meet the demand .
I would like to ask if there is a sentence , And it can also be used to solve this problem when paging is available , I beg your guidance .
Perfect solution to paging problems :
select * from yj_user order by cre_time<now(),if(cre_time<now(),0,cre_time),cre_time desc limit 0,10
bulongwind
Focus on
5
3
5
————————————————
Copyright notice : This paper is about CSDN Blogger 「bulongwind」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/bulongwind/article/details/70156493
边栏推荐
- AOSP ~ Logcat Chatty 行过期
- 怎样简洁明了地说清楚产品需求?
- SQL | return customer name, relevant order number and total price of each order
- ADVANCE. AI CEO Shoudong will share the compliance of cross-border e-commerce using AI technology at the 2022 emerging market brands online Summit
- [interview question 17.04. missing numbers]
- STC8A8K64D4 EEPROM读写失败
- 完成千万元A轮融资,小象生活能否成为折扣界的“永辉”?
- Cyclodextrin metal organic framework( β- Cd-mof) loaded with dimercaptosuccinic acid / emodin / quercetin / sucralose / diflunisal / omeprazole (OME)
- 学习太极创客 — ESP8226 (二)
- How to add two factor authentication for WordPress websites
猜你喜欢

Epoll principle and Application & ET mode and lt mode

Cyclodextrin metal organic framework( β- Cd-mof) loaded with dimercaptosuccinic acid / emodin / quercetin / sucralose / diflunisal / omeprazole (OME)

Jetpack compose scaffold and topappbar (top navigation)

软件测试英语常见词汇

Jetpack Compose Scaffold和BottomAppBar(底部导航)

WordPress article directory plug-in luckywp table of contents setup tutorial

How to read PMBOK guide in 3 steps (experience + data sharing)

How to fix syntax errors in WordPress websites

Setting access to win10 shared folder without verification
![Fundamentals of deep learning [4] build easyocr and carry out simple character recognition from 0](/img/e5/31ad2023def9e1a4a5fccb19b31d02.png)
Fundamentals of deep learning [4] build easyocr and carry out simple character recognition from 0
随机推荐
error exepected identifier before ‘(‘ token, grpc 枚举类编译错误
Baidu submits sitemap to prompt the solution of "index type is not handled"
CPT 102_LEC 13-14
Explanation of spark common parameters
A collection of common ADB commands for app testing
重磅直播!ORB-SLAM3系列之特征匹配(MLPnP、词袋模型等)。
P4338 [zjoi2018] history (tree section) (violence)
How to read PMBOK guide in 3 steps (experience + data sharing)
MySQL backup and recovery
CPT 102_LEC 20
A数位dp
剑指 Offer II 079. 所有子集
Byte beating | the first batch of written examination for game R & D post (question solution)
AOSP ~ 默认开启开发者模式
Epoll principle and Application & ET mode and lt mode
Win10 安装Office 2016出现错误代码30204-44怎么处理?
jdbc工具類的問題
String operation methods: replace, delete and split strings
[interview question 17.04. missing numbers]
When the interviewer opens his mouth, he comes to compose. Is this the case now?