【问题标题】:#1052 - Column 'courses' in where clause is ambiguous#1052 - where 子句中的“课程”列不明确
【发布时间】:2017-03-14 05:14:40
【问题描述】:

这是我的代码:

SELECT all_university.*, 
       all_colleges.* 
FROM all_university 
INNER JOIN all_colleges ON all_colleges.stateid = all_university.stateid 
WHERE courses LIKE '%BTech%'

这里我想要来自all_universityall_colleges 的所有数据,其中stateid 在两个表中都很常见,但是当我运行查询时,where 条件会引发错误

#1052 - Column 'courses' in where clause is ambiguous. How can I remove this.

谢谢

【问题讨论】:

  • 是的,两张桌子上都有课程。
  • 使用别名来区分。 all_colleges.courses
  • 对通用名称字段使用别名
  • 选择 all_university 。 * , all_colleges 。 * FROM all_university as au INNER JOIN all_colleges ON all_colleges.stateid = au.stateid where course like '%BTech%'
  • 它显示错误 #1051 - 未知表 'all_university'

标签: javascript php jquery html mysqli


【解决方案1】:

您必须在 where 子句中指定带有文件名的表。 您的查询将是这样的。

SELECT all_university . * , all_colleges . * FROM all_university INNER JOIN all_colleges ON all_colleges.stateid = all_university.stateid where all_university.courses like '%BTech%'

SELECT all_university . * , all_colleges . * FROM all_university INNER JOIN all_colleges ON all_colleges.stateid = all_university.stateid where all_colleges.courses like '%BTech%'

我不知道哪个表包含courses 列。这就是为什么两个查询

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-16
    • 1970-01-01
    • 2020-10-13
    • 2019-04-14
    • 1970-01-01
    • 2021-10-11
    相关资源
    最近更新 更多