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
This article mainly introduces several scheduling...
If you set the table-layer:fixed style for a tabl...
Table of contents 1. Encapsulate complex page dat...
This article shares the specific code of Vue to r...
Table of contents Avoid repetitive rendering loop...
WebService Remote Debugging In .NET, the remote d...
1. Understand the WEB Web pages are mainly compos...
This article shares the specific code of Node.js+...
Linux version: CentOS 7 [root@azfdbdfsdf230lqdg1b...
Table of contents 1. Overview 2. Parameters for c...
Table of contents illustrate 1. Blob object 2. Fr...
This article example shares the specific code of ...
Problem Record Today I was going to complete a sm...
1. Apache server installation and configuration y...
HTML+CSS+JS imitates win10 brightness adjustment ...