1.  查询数据库中yanfriends_article表中所有的为'201'的cid字段,查询结果按照ctime字段(本身为text,转为int类型比较)的递增展示

select * 
from yanfriends_article
WHERE cid = '201'
ORDER BY CAST(ctime AS INT )

2.  查询研友表中title包括:打算考研?这些必备常识你知道吗?的记录

select *
from yanyou
where title like '%打算考研?这些必备常识你知道吗?%'

3. 删除yanyou表中所有id大于1000的记录

DELETE
FROM yanyou
WHERE id > 1000

4. 创建数据表

CREATE TABLE head
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
pic TEXT,
intro TEXT
)

5.  查询表中有多少条记录(可加where查询条件)

SELECT COUNT(*) FROM yanyou
where cid = '13'

6. 查询表中指定字段的多条件满足

SELECT * FROM yanyou WHERE cid IN ("207","206","205","208","209")

7. 查询某个字段 有哪些不同的值

SELECT DISTINCT cname FROM yanyou

8. 查询表中十条数据

SELECT * FROM yanyou_copy1 LIMIT 10

9. 查询表中所有数据,查询结果按照ctime字段排序,DESC为降序排列,LIMIT 0,10可以限制查询出的结果个数,此例为只取前十个。

SELECT * FROM yanyou ORDER BY CAST(ctime AS INT) DESC
SELECT * FROM yanyou_copy1 ORDER BY CAST(ctime AS INT ) DESC LIMIT 0,10

10. sqlite插入某个字段随机数

180正负100

sql = "UPDATE yanfriends_head SET share = 180+(random()/(-9223372036854775808/100));"

-random() 的返回值范围是:[-2^63,(2^63)-1],即为: -9223372036854775808 到 9223372036854775807