如果我有两个表,列
TABLE 1: [_id,info]
TABLE 2: [_id,date]
并创建一个连接如何解决生成的Cursor中_id列的歧义,并且只能访问表2的_id列?
答案 0 :(得分:8)
通常,如果您有不明确的列名,可以使用别名来区分它们。
SELECT
t1._id as t1_id,
t2._id as t2_id
FROM ...
JOIN ...
在这种情况下,我猜你正在加入_id字段是平等的。然后你只能选择一次:
SELECT
T2._id as id
T1.info,
T2.date
FROM table1 AS T1
JOIN table2 AS T2
ON T1._id = T2._id