Home  >  Article  >  Backend Development  >  Column 'languageid' in where clause is ambiguous异常

Column 'languageid' in where clause is ambiguous异常

WBOY
WBOYOriginal
2016-06-13 10:56:541996browse

Column 'languageid' in where clause is ambiguous错误
我要进行多表查询,而languageid两个表中都该字段,网上的解决方法是在WHERE 后的条件字段中加上表名
where tablea.classid=xxx and tableb.classid=xxx
但是因为我的条件无论对tablea,tableb都是一样的,非要这么麻烦的写吗

------解决方案--------------------
当然不必写这么麻烦,判断的条件一样,就尽量写精点,不要那么多判断,这样反而对MySQL引擎有不好的影响。
------解决方案--------------------
表联合查询的时候,有相同字段必须在字段加面加上表名或者表的别名.
一般遇到这种情况都用表的别名.

如:
select t1.id, t2.id from table1 as t1, table2 as t2 where t1.id = t2.id
------解决方案--------------------
区分多个table就需要
------解决方案--------------------
一定要指定从那个表里拿languageid。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn