加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite: ambiguous column name解决方法

发布时间:2020-12-12 20:11:06 所属栏目:百科 来源:网络整理
导读: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, 很奇怪的是我只查

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,th.gid as gid,gName

from tempHum as th,igroup as gr

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

就是加粗的那几个代码。

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读