Mysql返回未知列" users.status"在" where子句"
SELECT
users.firstname,
users.lastname,
users.email,
users.pref
FROM (
SELECT
users.firstname,
users.lastname,
users.email,
CONCAT(
users.preference, ',',
) AS pref
FROM users
) AS users
WHERE users.status = 1
AND users.active = 1
答案 0 :(得分:0)
子查询不包含status
列。为什么不在没有子查询的情况下编写查询?
SELECT u.firstname, u.lastname, u.email,
CONCAT(u.preference, ',') AS pref
FROM users u
WHERE u.status = 1 AND u.active = 1;
你在CONCAT()
的末尾还有一个额外的逗号(看起来很奇怪,只有两个参数)。