MySQL paging processing (pagehelper)

Source: Internet
Author: User

Do pagination for the first time (no idea what the paging process is going to do?) )

Understanding: Actually is the foreground page by passing different parameters {1. The condition of the query. 2. Number of pages (Pagenum), 3 per page (pageSize)}, after we (only to do the background data processing (display to the foreground of the correct information is OK), regardless of the reception to take these data dry yarn.

[
{
"id": 64,
"Name": "Fdsaf"
}
]

Format these I'm using postman get Test (reverse is exactly this format)

  

. No matter what SQL query, first in the XXXX visualization tool inside the foreground may need to all the data query out (if you use the command window cool, no way can only say "old driver with Me"), (in fact, write a big idea, then a series of modified SQL statements, Personal feeling more convenient)

Note:

1
<if test= "Name! = NULL and name! = '" >
and name like '%${name}% '
</if>
Go

1. String concatenation in SQL

SELECT * from TableName where name is like CONCAT (CONCAT ('% ', #{text}), '% ');

2. Use ${...} instead of #{...}

SELECT * from TableName WHERE name is like '%${text}% ';

(This is what the SQL statement of the hemp Egg originally wrote.) I have been debugging for a long time because the original company directly fuzzy query is '% ' +{name}+ '% '  but not. I use the second kind directly)

2 interfaces queried in the Mapper.java file require fields to query otherwise you know
  
List<category> FindAll (@Param ("name") String name) throws Exception;

Pagehelper using:

Pagehelper.startpage (currenpage,pagesize); ----->  These are the pagehelper that the front desk  can send directly .
list<category> list = Categorymapper.findall (name);

List is the result you want to return


MySQL Paging processing (pagehelper)

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.