SQL in the Mapper file:
--------------------------------------------------------------------------------------------
(attributes defined in the entity class)
Start: Starts with the first few records.
Size: Reads several records.
Select Id= "Findallusers" parametertype= "Map" resulttype= "entity. Iuser ">
SELECT * FROM NewUsers
<where>
User_name like #{user_name,jdbctype=varchar}
</where>
Limit #{start,jdbctype=integer},#{size,jdbctype=integer}
</select>
-------------------------------------------------------------------
Front End Will page: Page No.
Rows (size): How many bars per page
These two parameters are uploaded to the background.
Using these two parameters, we can calculate the start calculation method Start=size (page-1)
Then put the size and start into the map
Simple code example
Map map=new HashMap ();
Map.put ("Start", start);
Map.put ("size", size);
Don't forget to convert start and size to integer.
It then passes the map as a parameter to the DAO's interface.
Note:
Limit is the syntax of MySQL
SELECT * FROM table limit M,n
where m refers to the beginning of the record index, starting from 0, indicating the first record
n means starting from section m+1 and taking N.
SELECT * FROM tablename limit 2,4
Take out 3rd to 6th, 4 records
Turn from: https://zhidao.baidu.com/question/266421833.html and http://www.cnblogs.com/yululiang/p/6497534.html convenient for later search
LIMIT usage in MYSQL