Sqlite—查询语句(Select)

基本语法如下

sqlite> select * from tb_user;
sqlite> select userid,username from tb_user;

格式化的查询输出

sqlite> .header on
sqlite> .mode column
sqlite> select * from tb_user;

设置输出列的宽度

sqlite> .width 10, 20, 10
sqlite> select * from tb_user;

SQLite 的 ORDER BY 子句是用来基于一个或多个列按升序或降序顺序排列数据。

基本语法:SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC];

sqlite> select * from tb_user order by name asc;        -- 结果按 name 升序排序:
sqlite> select * from tb_user order by name desc;       -- 结果按 name 降序排序:
sqlite> select * from tb_user order by name,age asc;    -- 结果按 name 和 age升序排序:

  

你可能感兴趣的:(Sqlite—查询语句(Select))