>  기사  >  데이터 베이스  >  sqlite: ambiguous column name解决方法

sqlite: ambiguous column name解决方法

WBOY
WBOY원래의
2016-06-07 15:21:542282검색

sqlite: ambiguous column name解决方法 SQLite数据库查询中的BUG 如下语句: select t_id,t_name,t_address,gid ,deviceName,gName from tempHum as th,device as de,igroup as gr where th.deviceid = de.deviceid and th.gid = gr.gid 在执行时报: ambig

sqlite: ambiguous column name解决方法

 

SQLite数据库查询中的BUG

 

   如下语句:

    select t_id,t_name,t_address,gid ,deviceName,gName

    from tempHum as th,device as de,igroup as gr 
   where th.deviceid = de.deviceid and th.gid = gr.gid

 

在执行时报:

ambiguous column name:gid,

 

 

   很奇怪的是我只查询了一遍gid列,因为gid在两张表里面都有,一张里面是主键,一张里面是外键。而且在Mysql中没有出现这样的错误,很是奇怪。

 

以前碰到过,因为当时用的是 select * ......,又因为那一列没有用,所有就没管,今天出现类似的情况,却无法避免,经过摸索已解决

 

select t_id,t_name,t_address,th.gid as gid,deviceName,gName

from tempHum as th,device as de,igroup as gr

where th.deviceid = de.deviceid and th.gid = gr.gid

 

 

就是加粗的那几个代码。

 

问题虽不大,但终究是解决了,留个念。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.