#1052 - where子句中的列'courses'是不明确的

时间:2017-03-14 05:14:40

标签: javascript php jquery html5 mysqli

这是我的代码:

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.

谢谢

1 个答案:

答案 0 :(得分:2)

您必须在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列。这就是为什么两个查询