1. Introduction I recently upgraded my blog and added two buttons at the bottom of the article page, which can jump directly to the previous and next article. As shown in the following figure: The difficulty in implementing this function lies in: how does the database select the two adjacent records before and after a record? 2. Database Design The design of my article database is shown below: As you can see, the identity of each record is the index Id. Because many article records were deleted before, the IDs are not continuous. If the index value of the current article is 33, you can use the following command to get the two adjacent articles: select * from passage where id in (select case when SIGN(id - 32 )>0 THEN MIN(id) when SIGN(id - 32 )<0 THEN MAX(id) end from passage where id != 34 GROUP BY SIGN(id - 32 ) ORDER BY SIGN(id - 32 ) ) ORDER BY id; 3. Unable to select aggregate columns When executing the above command, Mysql gave me an error: The following is the original text:
Therefore, we should set sql_mode not to include Enter the mysql configuration file, add the following configuration in the [mysqld] section, and restart mysql. [mysqld] # ... other config sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATEERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION # delete 'only_full_group_by' # ... other config Run the mysql command in the second part of this article, and the result is as shown below: 4. Related links only_full_group_by 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:
|
>>: react-diagram serialization Json interpretation case analysis
introduction As usual, let's start with a sce...
Table of contents Preface Direct filling method f...
Our veteran predecessors have written countless c...
The solution to the problem that mysql cannot be ...
How to use CSS to control the arc movement of ele...
Achieve results Implementation Code html <div ...
1. First, double-click the vmware icon on the com...
ask: I have styled the hyperlink using CSS, but i...
Win2008 R2 zip format mysql installation and conf...
Database backup #grammar: # mysqldump -h server-u...
Table of contents 1.sleep function 2. setTimeout ...
1. Command Introduction bzip2 is used to compress...
JavaScript shows and hides pictures, for your ref...
Here is a case of modal box dragging. The functio...
Table of contents Component Design Defining the f...