我有一个查询:
SELECT b.user_id, b.active FROM users b
WHERE b.followers_count != (SELECT COUNT(*)
FROM (SELECT u.user_id
FROM user_follow uf,users u,user_follow_request ufr
WHERE
uf.following_id = b.user_id AND
uf.following_id = ufr.friend_id AND
ufr.status = 'approved' AND
ufr.user_id = u.user_id AND u.user_id != b.user_id AND u.active != 0
GROUP BY u.user_id) a)
AND b.active = -1 limit 5;
它必须从列中选择与 sql 计算的列不同的所有user_id
' 。users
followers_count
但问题是我收到错误消息
Error Code: 1054. Unknown column 'b.user_id' in 'on clause'
我做错了什么?非常感谢您的帮助。