这是我的代码:
SELECT all_university.*,
all_colleges.*
FROM all_university
INNER JOIN all_colleges ON all_colleges.stateid = all_university.stateid
WHERE courses LIKE '%BTech%'
在这里,我希望all_university
和all_colleges
中的所有数据stateid
在两个表中都很常见,但是当我运行查询时,where条件会引发错误
#1052 - Column 'courses' in where clause is ambiguous. How can I remove this.
谢谢
答案 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
列。这就是为什么两个查询