Sqlite 查询错误:列名不明确?
我正在 sqlite3 数据库上运行以下查询:
SELECT file.id AS fileID, file.path
FROM file
JOIN (SELECT tag_file_map.fileID,tag.tagname
FROM tag_file_map, tag JOIN tag ON tag_file_map.tagID = tag.id)
ON tag_file_map.fileID = file.id
WHERE tag.tagname = 'tag1' AND tag.tagname= 'tag2';
它给了我以下错误:“不明确的列名:tag.tagname”
Google 似乎说当一个或多个表共享一个表时会产生此错误未指定列名和该列的具体表。然而,这里指定了表名。另外,整个数据库中没有其他名为“tagname”的列,因此无论有没有表名都不应该产生歧义。这是一个 sqlite 问题,还是我的语法有问题?
I am running the following query on an sqlite3 database:
SELECT file.id AS fileID, file.path
FROM file
JOIN (SELECT tag_file_map.fileID,tag.tagname
FROM tag_file_map, tag JOIN tag ON tag_file_map.tagID = tag.id)
ON tag_file_map.fileID = file.id
WHERE tag.tagname = 'tag1' AND tag.tagname= 'tag2';
It gives me the following error: "ambiguous column name: tag.tagname"
Google seems to say that this error is produced when one or more tables share a column name and the specific table of the column is not specified. However, here, the table name IS specified. Plus, there is no other column with the name "tagname" in the entire database, so it shouldn't be ambiguous with or without the table name. Is this an sqlite problem, or is something off with my syntax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在你内心的选择上,更改
为
on you inner select, change
to
我认为这会起作用...
I think this will work...