Sqlite—查询语句(Select)

基本语法如下

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

格式化的查询输出

sqlite> .header onsqlite> .mode columnsqlite> select * from tb_user;

设置输出列的宽度

sqlite> .width 10, 20, 10sqlite> 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 的 Distinct 关键字

基本语法:SELECT DISTINCT column1, column2,.....columnN FROM table_name WHERE [condition]

sqlite> select distinct name from tb_user;sqlite> select distinct name,age from tb_user;sqlite> select distinct name,age from tb_user where name="liu";

  

(0)

相关推荐