Ambiguous column names in android

android, java, sqlite

Solution

In general if you have ambiguous column names you can distinguish between them by using aliases.

SELECT
    t1._id as t1_id,
    t2._id as t2_id
FROM ...
JOIN ...

In this case I'm guessing that you are joining on the _id field being equal. Then you can select it only once:

SELECT
    T2._id as id
    T1.info,
    T2.date
FROM table1 AS T1
JOIN table2 AS T2
ON T1._id = T2._id

Problem

If I have two tables, with columns ``` TABLE 1: [_id,info] TABLE 2: [_id,date] ``` and make a join how can I resolve the ambiguous of the _id columns in the resulting Cursor and access only to the column _id of the table 2?

Original source