#1054 - 未知列 - 反引号问题

时间:2016-02-14 18:39:53

标签: php mysql database mariadb

基本上,我有这个问题:

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' 代表`),依此类推。我知道它与这些反叛有关,但我无法弄清楚它是如何工作的。谢谢!

1 个答案:

答案 0 :(得分:1)

正如您已将别名添加到'群组'表 - ' g',查询不再识别具有groups名称的表,您需要使用别名,因此您需要更改 groupsgoodname到g。goodname

SELECT *, g.`goodname`
FROM students AS s
INNER JOIN groups AS g
        ON s.univ_group = g.id
WHERE name LIKE "%А%"