sqllite3的常用语句
1.模糊查询
select * from 表 where 字段 like "%搜索字%"
2. 查出有几个表
select * from sqlite_master where type="table"
type(table) name(表名) tbl_name(表名) rootpage sql(sql语句)
3.混合
update 表 set 列名=值 where 列名 LIKE ‘%搜索字%’
4.查询前10条数据
- select * from 表 order by 列名 desc limit 0,10; (desc 是升序,不写默认是asc)
3.C++获得结果集
sqlite3_get_table(sqlite3 *db,const char *sql,char ***result,int *rowCount, int *colCount,char **errorMessage)
(1)db为数据库的指针,sql为要执行的sql语句,rowCount为查询的行数,colCount为列数,errorMessage为错误信息
(2)result的数据是连续的(字段名然后是一行一行的数据),则取第二行第三列数据则为result[3*colCount+3]