// 創(chuàng)建表
create table ScoreTable (idx INTEGER PRIMARY KEY AUTOINCREMENT, userid INTEGER, skuid INTEGER)
// 插入數(shù)據(jù)
insert into ScoreTable (userid, skuid) values (%ld,%ld)
// 刪除數(shù)據(jù)
delete from ScoreTable where userid = %ld and skuid = %ld
// 修改數(shù)據(jù)
update ScoreTable set mission_use_time = %lld? where userid = %ld and skuid = %ld
// 查詢相應id的數(shù)據(jù)
select * from words where id = %d
// 隨機取三條 words 表中的 word,其中 id 不能為%ld, word 不能為空,不等于null
select word from words where id != %ld and word !='' and word is not null order by random() limit 3
// 查詢 word_prop 表中的 wordId 不在 words 表 id 中的數(shù)據(jù)
select * from word_prop where wordId not in(select id from words)
// 查詢word_prop中的數(shù)據(jù)個數(shù)
select count(*) from word_prop
// 查詢 word_prop 表中 wordId 重復的數(shù)據(jù)
select * from word_prop group by wordId having count(*) > 1
// 查詢 wordId 為8354的數(shù)據(jù)
select * from word_prop where wordId = 8354
// 更新 userid 列的數(shù)據(jù)都置為11
update ScoreTable set userid = 11
// 查詢兩個表相差的數(shù)據(jù)(a為數(shù)據(jù)多的表,b為數(shù)據(jù)少的表)
select * from a LEFT JOIN b ON b.word_id = a.id WHERE b.word_id is null
// 查詢一個表中synchronize為0的數(shù)據(jù) (至少10條數(shù)據(jù))
select * from WordStateTable where userid = '3410209' and skuid = '4' and synchronize = 0 LIMIT 10
// 查詢一個表中spokenid 為9999的插入最早的數(shù)據(jù)
select * from SpokenTestsTable where spokenid = '99999' order by idx limit 0,1
// 根據(jù)userId、skuid、spokenId獲取今天新增的個數(shù),如果在今天之前已經(jīng)插入過的spokenId則不算(去重),createTime/1000---時間戳使用10位的
select count(DISTINCT t.spokenId) from SpokenTestsTable t where t.userId = %d and t.skuid = %ld and date(datetime(t.createTime/1000, 'unixepoch','localtime')) = date('now') and (select count(1) as num from SpokenTestsTable st where st.userId = t.userId and st.skuid = t.skuid and st.spokenId = t.spokenId and date(datetime(st.createTime/1000,'unixepoch','localtime')) < date('now')) = 0