基本上,我有这个问题:
SELECT *, `groups`.`goodname`
FROM students AS s
INNER JOIN groups AS g
ON s.univ_group = g.id
WHERE name LIKE "%А%"
它在查询尝试时出现此错误:#1054 - Unknown column 'groups.goodname' in 'field list'
由于SO标记原因,已经尝试'groups'.goodname, 'groups.goodname', goodname.'groups', goodname.groups
(' 代表`),依此类推。我知道它与这些反叛有关,但我无法弄清楚它是如何工作的。谢谢!
答案 0 :(得分:1)
正如您已将别名添加到'群组'表 - ' g',查询不再识别具有groups
名称的表,您需要使用别名,因此您需要更改
groups
。goodname
到g。goodname
SELECT *, g.`goodname`
FROM students AS s
INNER JOIN groups AS g
ON s.univ_group = g.id
WHERE name LIKE "%А%"