【问题标题】:I am trying to do a join table and I am getting ambiguous column error我正在尝试做一个连接表,但我得到了不明确的列错误
【发布时间】:2021-08-03 02:27:00
【问题描述】:

我想加入两个表、联系人和组。我想从联系人中的组列与组中的组列匹配的联系人中获取 firstName 列。当我输入我的声明时,联系人中的任何一列都说它是模棱两可的。

cursor.execute('SELECT groups.groups FROM contacts, groups LEFT JOIN contacts ON contacts.groups = groups.groups')

【问题讨论】:

  • 提示 - 逗号不应出现在 from 子句中。

标签: sql join left-join


【解决方案1】:

您包含两次联系人表 我觉得你应该这样做

select contacts.firstname
from contacts
left join groups 
on contacts.groups=groups.groups

【讨论】:

    猜你喜欢
    • 2016-08-20
    • 2020-03-15
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多