Mysql PageHelper and mysqlpagehelper

Source: Internet
Author: User
Tags what sql

Mysql PageHelper and mysqlpagehelper

The first paging processing (I don't know what paging processing will do ?)

Understanding: in fact, the front-end page passes different parameters {1. query conditions. 2. page number (pageNum), 3 the number of items displayed per page (pageSize)}, then we (only process data in the background (if the front-end data is displayed correctly, OK ), no matter whether the front-end uses the data to dry the wool)

[
{
"Id": 64,
"Name": "fdsaf"
}
]

The format is the postman get test (this format is used anyway)

  

. No matter what SQL query is done, first query all the data that may be needed in the foreground in the xxxx visualization tool (if you cannot use the command window, there is no way to say "the old driver takes me with me") (in fact, it is more convenient to write a series of SQL statements and then modify them)

Note:

1
<If test = "name! = Null and name! = ''">
AND name LIKE '% $ {name} %'
</If>
(Transfer)

1. String concatenation in SQL

SELECT * FROM tableName WHERE name like concat ('%', # {text}), '% ');

2. Use $ {...} Instead #{...}

SELECT * FROM tableName WHERE name LIKE '% $ {text} % ';

(The SQL statement used to be written in this way. I have been debugging for a long time because the company's direct fuzzy query is '%' + {name} + '%', but it cannot. The second method I used directly)

2. The fields to be queried by the interface queried in the mapper. java file must be @ Parem ("xxx") or you will understand
  
  List<Category> findAll(@Param("name") String name)throws Exception; 

PageHelper usage:

PageHelper. startPage (currenPage, pageSize); ----->PageHelper can be used directly
 
List <Category> list = categoryMapper. findAll (name );

List is the result returned.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.