sqilte 语句

1、创建表格

CREATE TABLE IF NOT EXISTS  AccountTable  ('id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,accountID TEXT ,password TEXT )

2、Sqlit 里查询获取N条数据

查询条件 whereSql 按somthingelse 降序排序 取从第 0条开始后的N条数据 (ASC升序 ,DESC降序)

SELECT FROM table_Name WHERE whereSql ORDER BY somethingelse DESC LIMIT 5, N

3、说明:几个简单的基本的sql语句
 

选择:select * from table1 where 范围
插入:insert into table1(field1,field2) values(value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1=value1 where 范围
查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料!
排序:select * from table1 order by field1,field2 [desc]
总数:select count as totalcount from table1
求和:select sum(field1) as sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(field1) as minvalue from table1

4、删除数据库
drop database dbname

5、使用外连接 
A、left (outer) join: 
左外连接(左连接):结果集几包括连接表的匹配行,也包括左连接表的所有行。 
 

SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c


B:right (outer) join: 
右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。 
C:full/cross (outer) join: 
全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。

你可能感兴趣的:(sqlite)