1

如果我有两个表,有列

TABLE 1: [_id,info]

TABLE 2: [_id,date]

并进行连接如何解决结果游标中 _id 列的歧义并仅访问表 2 的列 _id?

4

1 回答 1

10

通常,如果您有不明确的列名,您可以使用别名来区分它们。

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
于 2012-04-18T08:34:36.943 回答