query(uri, projection, selection, selectionArgs, sortOrder)添加 limit条件 查询语句出错,求指导,先谢了

黛曦葛溪 发布于 2015/05/20 16:49
阅读 641
收藏 0
Cursor c = cr.query(Data.CONTENT_URI, GroupDetailQuery.PROJECTION, Data.MIMETYPE + " = ? AND "
                + GroupMembership.GROUP_ROW_ID + " = ? "+"limit 5", new String[] {
                GroupMembership.CONTENT_ITEM_TYPE, String.valueOf(groupID)},
                null);
//上面的查询语句写了“limit 5” 但是查询的时候报错 ,但是下面这条就是正常的,请问上面的查询条件该怎么写limit?
 select raw_contact_id,data1,_id from data where data_version=0 and raw_contact_id=7  limit 1


第一条查询错误如下:


E/DatabaseUtils(4873): android.database.sqlite.SQLiteException: near "limit": syntax error (code 1): , 
while compiling: SELECT DISTINCT contact_id, photo_uri, lookup, display_name, agg_presence.mode AS contact_presence, 
contacts_status_updates.status AS contact_status, photo_id, 
photo_uri, display_name_alt FROM view_data data LEFT OUTER JOIN agg_presence 
ON (contact_id = agg_presence.presence_contact_id) LEFT OUTER JOIN status_updates contacts_status_updates 
ON (status_update_id=contacts_status_updates.status_update_data_id) LEFT OUTER JOIN 
(SELECT data_usage_stat.data_id, SUM(data_usage_stat.times_used) as times_used,
 MAX(data_usage_stat.last_time_used) as last_time_used FROM data_usage_stat GROUP BY data_id) as data_usage_stat ON 
(data_usage_stat.data_id=data._id) WHERE (1) AND ((mimetype = ? AND data1 = ? limit =5)) 

加载中
返回顶部
顶部