android ContentResolver 多表联合查询

 

			String [] projection= new String[]{
			Phones._ID,
			Phones.TYPE,
			Phones.NUMBER,
			"(SELECT NAME FROM PEOPLE AS people WHERE PEOPLE._id =PERSON) AS peopleName",
//			new StringBuilder().append("(SELECT NAME FROM PEOPLE AS people WHERE PEOPLE._id =").append(Phones.PERSON_ID)
//			.append(") AS peopleName").toString(),
			"(SELECT DATA FROM PHOTOS AS PHOTOS WHERE PHOTOS.PERSON =PERSON) AS peopleLogo",
//			new StringBuilder().append("(SELECT DATA FROM PHOTOS AS PHOTOS WHERE PHOTOS.PERSON =").append(Phones.PERSON_ID)
//			.append(") AS peopleLogo").toString()
			
		}; 	

		String selection = "0==0) GROUP BY (PERSON";
		Cursor cursor = context.getContentResolver().query(Phones.CONTENT_URI, projection, selection, null, null);
		while(cursor.moveToNext()){
			System.out.println(cursor.getString(cursor.getColumnIndex(Phones.NUMBER)));
			System.out.println(cursor.getString(cursor.getColumnIndex("peopleName")));
		}

你可能感兴趣的:(android ContentResolver 多表联合查询)