Hi, I have two tables:

Category(_id, name)
Spend(_id, spend, category_id)

I want to join these two tables. I tried to use CursorJoiner:

        Cursor spendCursor = managedQuery(
                AccountBook.Spend.CONTENT_URI,
                new String[] { AccountBook.Spend._ID,
AccountBook.Spend.SPEND, AccountBook.Spend.CATEGORY_ID },
                null, null, AccountBook.Spend.CATEGORY_ID
        );

        Cursor categoryCursor = managedQuery(
                AccountBook.Category.CONTENT_URI,
                new String[] { AccountBook.Category._ID,
AccountBook.Category.NAME },
                null, null, AccountBook.Category._ID
        );

        CursorJoiner joiner = new CursorJoiner(
                spendCursor, new String[] { AccountBook.Spend.CATEGORY_ID },
                categoryCursor, new String[] { AccountBook.Category._ID }
        );

With following data:

Spend's category_id: 1, 1, 1, 1, 2
Category's _id: 1, 2, 3

I got following results of CursorJoiner :

BOTH
LEFT
LEFT
LEFT
BOTH
RIGHT

That's strange, it seems the behavior of CursorJoiner is not like the
behavior of join of usual database. What I want is, list all spends in
list with its category's name.

For example:

Spends (_id, spends, category_id) :
1, 999, 1
2, 55, 2
3, 30, 2
4,, 60, 3

Categories (_id, name):
1, food
2. tips
3. 3C products

And I want the list looks like:

(spend.spend, category.name)
999, food
55, tips
30, tips
60, 3C products

How can I achieve this with Android?

Thanks.
Victor Lin.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to