0

My issue is simple. I'm doing a JOIN rawQuery() to get columns User._id and Teacher._id and the tables from users AS User join teachers AS Teacher

The cursor seems not to care about the alias so it overrides User._id value with Teacher._id cause both columns are just _id for the Cursor

How can I solve this? i need all that data in 1 cursor so having 2 cursors isn't an option

Edit: I want to avoid changing or renaming the column _id because of the design patters, isn't there a way to use alias for tables as in MySQL?

Edit 2: or maybe changing the column name but only inside the Cursor, not the actual column name

matreshkin
  • 2,199
  • 18
  • 28
Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206
  • You are renaming the **tables**, not the **columns**... – Phantômaxx Apr 01 '14 at 20:07
  • what do you get if you print the column names in the cursor ? (you probably can infer the column indexes from the query, and use that instead of getColumnIndex(), too) – njzk2 Apr 01 '14 at 20:08
  • 1
    as @Vyger suggests, you can create aliases for your columns, rather that for your tables. `select User._id as userid, Teacher._id as teacherid ...` – njzk2 Apr 01 '14 at 20:10

1 Answers1

0

I think the solution is very simple. First rename one of the columns, and then try to JOIN them. I think this will be useful for you: rename column

Community
  • 1
  • 1