我想显示一个mysql数据库表,每次显示(查询)10行,例如我有这个表id = +--------------------------------------+--------+
| id | name |
+--------------------------------------+--------+
| 32dcad0b-3cc3-11e8-952b-708bcd9109ce | item0 |
| 32e07686-3cc3-11e8-952b-708bcd9109ce | item1 |
| 32e07772-3cc3-11e8-952b-708bcd9109ce | item2 |
| 32e077af-3cc3-11e8-952b-708bcd9109ce | item3 |
| 32e077f2-3cc3-11e8-952b-708bcd9109ce | item4 |
| 32e07825-3cc3-11e8-952b-708bcd9109ce | item5 |
| 32e078bf-3cc3-11e8-952b-708bcd9109ce | item6 |
| 32e07954-3cc3-11e8-952b-708bcd9109ce | item7 |
| 32e0798c-3cc3-11e8-952b-708bcd9109ce | item8 |
| 32e07a26-3cc3-11e8-952b-708bcd9109ce | item9 |
| 32e07a5a-3cc3-11e8-952b-708bcd9109ce | item10 |
| 32eacb03-3cc3-11e8-952b-708bcd9109ce | item11 |
| 32eacb83-3cc3-11e8-952b-708bcd9109ce | item12 |
| 32eacbb2-3cc3-11e8-952b-708bcd9109ce | item13 |
| 32eacbe0-3cc3-11e8-952b-708bcd9109ce | item14 |
| 32eacc0e-3cc3-11e8-952b-708bcd9109ce | item15 |
| 32eacc37-3cc3-11e8-952b-708bcd9109ce | item16 |
| 32eacca3-3cc3-11e8-952b-708bcd9109ce | item17 |
| 32eaccd1-3cc3-11e8-952b-708bcd9109ce | item18 |
| 32eaccff-3cc3-11e8-952b-708bcd9109ce | item19 |
| 32eacd2d-3cc3-11e8-952b-708bcd9109ce | item20 |
| 32eacd56-3cc3-11e8-952b-708bcd9109ce | item21 |
| 32eacd85-3cc3-11e8-952b-708bcd9109ce | item22 |
| 32eacdae-3cc3-11e8-952b-708bcd9109ce | item23 |
| 32eacdd7-3cc3-11e8-952b-708bcd9109ce | item24 |
| 32eace00-3cc3-11e8-952b-708bcd9109ce | item25 |
| 32eace29-3cc3-11e8-952b-708bcd9109ce | item26 |
| 32eace57-3cc3-11e8-952b-708bcd9109ce | item27 |
| 32eace80-3cc3-11e8-952b-708bcd9109ce | item28 |
| 32eacea9-3cc3-11e8-952b-708bcd9109ce | item29 |
| 32eaced2-3cc3-11e8-952b-708bcd9109ce | item30 |
| 32eacefb-3cc3-11e8-952b-708bcd9109ce | item31 |
| 32eacf24-3cc3-11e8-952b-708bcd9109ce | item32 |
| 32eacf52-3cc3-11e8-952b-708bcd9109ce | item33 |
| 32eacf7b-3cc3-11e8-952b-708bcd9109ce | item34 |
| 32eacfa5-3cc3-11e8-952b-708bcd9109ce | item35 |
| 32eacfce-3cc3-11e8-952b-708bcd9109ce | item36 |
| 32eacff7-3cc3-11e8-952b-708bcd9109ce | item37 |
| 32ead025-3cc3-11e8-952b-708bcd9109ce | item38 |
| 32ead04e-3cc3-11e8-952b-708bcd9109ce | item39 |
| 32ead07c-3cc3-11e8-952b-708bcd9109ce | item40 |
+--------------------------------------+--------+
:
@ExceptionHandler(DataIntegrityViolationException::class)
protected fun handleDataIntegrityException(ex: DataIntegrityViolationException, request: WebRequest) : ResponseEntity<SomeBody>{
return ResponseEntity.badRequest().body(someBodyHere)
}
我如何选择前10项然后前20项 - 前10项...等等
答案 0 :(得分:0)
您可以使用如下所示的 LIMIT 子句。第一个参数是偏移量,第二个参数是要在偏移量后显示的行数。
SELECT id from TABLE Limit 0,10
SELECT id from TABLE Limit 10,10
SELECT id from TABLE Limit 20,10
...
答案 1 :(得分:-1)
SELECT name
FROM [table_name]
[ORDER BY name]
LIMIT [number_of_rows]