我在做查询时有一点错误。
它说:Unknown column 'friend_id' in 'on clause'
SELECT DISTINCT
CASE friends.user_id_1
WHEN 1 THEN friends.user_id_2
ELSE friends.user_id_1
END AS friend_id,
friends.created
/*users.name_surname,
users.avatar*/
FROM friends
JOIN users ON friend_id = users.id
WHERE 1 IN (friends.user_id_1, friends.user_id_2) /*AND friends.status = 1*/
问题显然是friend_id
,因为它不是一个真正的专栏。如何修复错误?