SQLite 基础16

2021-12-01 17:31:48 浏览数 (1)

LIMIT

代码语言:javascript复制
sqlite> select * from company;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0   
2           Allen       25          Texas       15000.0   
3           Teddy       23          Norway      20000.0   
4           Mark        25          Rich-Mond   65000.0   
5           David       27          Texas       85000.0   
6           Kim         22          South-Hall  45000.0   
7           James       24          Houston     10000.0   
sqlite> select * from company limit 3;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0   
2           Allen       25          Texas       15000.0   
3           Teddy       23          Norway      20000.0   
sqlite> select * from company limit 3 offset 3;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
4           Mark        25          Rich-Mond   65000.0   
5           David       27          Texas       85000.0   
6           Kim         22          South-Hall  45000.0   
sqlite>

ORDER BY

代码语言:javascript复制
sqlite> select * from company order by salary;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
7           James       24          Houston     10000.0   
2           Allen       25          Texas       15000.0   
1           Paul        32          California  20000.0   
3           Teddy       23          Norway      20000.0   
6           Kim         22          South-Hall  45000.0   
4           Mark        25          Rich-Mond   65000.0   
5           David       27          Texas       85000.0   
sqlite> select * from company order by salary desc;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
5           David       27          Texas       85000.0   
4           Mark        25          Rich-Mond   65000.0   
6           Kim         22          South-Hall  45000.0   
1           Paul        32          California  20000.0   
3           Teddy       23          Norway      20000.0   
2           Allen       25          Texas       15000.0   
7           James       24          Houston     10000.0   
sqlite> 

0 人点赞