I'm struggling with a weird issue with MySQL while using an inner join (although I'm not sure if that's the cause of it). My issue occurs when I try to select a column from a particular table (the column is ambiguous). I'm getting a friendly little error telling me that the column doesn't exist. (Unknown column 'items.id' in 'field list')
在使用内连接时,我正在努力解决MySQL的一个奇怪问题(虽然我不确定这是否是它的原因)。当我尝试从特定表中选择一列时(列不明确),我的问题出现了。我收到一个友好的小错误,告诉我该列不存在。 ('字段列表'中的未知列'items.id')
Anyway, here's my query:
无论如何,这是我的查询:
SELECT `items`.`id`, `chemical_name`, `full_name`, `amount`, `smiles`, `inchi`, `inchikey`, `average_mass`, `molecular_weight`, `monoisotopic_mass`, `nominal_mass` FROM `items` A INNER JOIN `chemicals` B ON A.csid = B.csid WHERE `owner` = '2'
Am I doing something wrong or is this some weird MySQL bug?
我做错了什么或者这是一些奇怪的MySQL错误?
Thanks
谢谢
1 个解决方案
#1
5
You use the alias A
for your table items
.
您为表项使用别名A.
use A.id
in your select instead of items.Id
and you should be fine
在你的选择中使用A.id而不是items.Id,你应该没事
#1
5
You use the alias A
for your table items
.
您为表项使用别名A.
use A.id
in your select instead of items.Id
and you should be fine
在你的选择中使用A.id而不是items.Id,你应该没事