如果对SQLite关键字用法不是太熟 ,推荐 http://www.yiibai.com/sqlite/sqlite_order_by.html
query(String table,String [] columns, String selection,String [] selectionArgs,String groupBy,String having, String orderBy,String limit)方法各参数的含义:
table:表名。相当于select *** from table语句中的table。如果是多表联合查询,可以用逗号将两个表名分开。 columns:要查询出来的列名。相当于select *** from table语句中的 ***部分。如果是查询多个参数,可以用逗号将两个表名分开。例:new String[]{"name","age","sex"}selection:查询条件子句,相当于select *** from table where && 语句中的&&部分,在条件子句允许使用占位符“?”表示条件值 ,例:"name=?,age=?,sex=?"
selectionArgs:对应于selection参数占位符的值,值在数组中的位置与占位符在语句中的位置必须一致,否则就会有异常。 例:与 new String[]{"lisa","1","女"}groupBy:相当于select *** from table where && group by ...语句中...的部分 ,作用是:将同一列的相同名字的参数合并在一起 例;在name列有两个Jame(name:Jame --salay:100,name:Jame --salay:200),使用...group by name查询后 只显示一个Jame的集合(name:Jame--salay:300) having:相当于select *** from table where && group by ...having %%%语句中%%%的部分, 作用于groupBy的条件,例:havig name>2意思是name列相同参数>2orderBy:相当于select ***from ?? where&& group by ...having %%%order by@@语句中的@@部分,如:personid desc(按person 降序), age asc(按age升序);limit:指定偏移量和获取的记录数,相当于select语句limit关键字后面的部分。
若有漏洞请指正
新闻热点
疑难解答