Preface In a previous project, the CASE WHEN sorting function in SQL was used. Now write a blog memo~ Database version: MySQL 5.6.42 condition: A field represents the state of the data and takes a non-negative integer value, where 0 means no state. need: Sort by this field in ascending order, and put the data with a value of 0 at the end. First, let's look at the structure of the table: The normal query result in ascending order is as follows: To put "小赤" at the end, you can write: You can also do this: You can also use CASE WHEN to change the sorting basis without affecting the query results: Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: How to smoothly upgrade and rollback Nginx version in 1 minute
>>: Vue uses custom instructions to add watermarks to the bottom of the page
Here is a common one-click performance test scrip...
Preface After a failover occurs, a common problem...
Binlog is a binary log file that is used to recor...
The scroll bar position is retained when scrollin...
Today I will talk to you about clearing floats. B...
Official documentation: https://dev.mysql.com/doc...
Fault site: Log in to the MySQL server and get th...
Table of contents Methods that do not change the ...
1. Download MySQL Log in to the MySQL official we...
In a recent problem, there is such a phenomenon: ...
1. CSS style solves the problem of displaying ell...
How to center your HTML button itself? This is ea...
I don't know if it's because the binary d...
Detailed example of MySQL exchange partition Pref...
Problem Description Several machines recently dis...