我有这个 MySQL 声明:
SELECT a.id, a.`from member_id`, a.`to member_id`, IF(a.`from member_id`=1, a.`to member_id`, a.`from member_id`) as other_id, a.text, MAX(a.`date sent`) as `date sent`
FROM message a
JOIN members m on other_id=m.id
WHERE (a.`from member_id`=1 OR a.`to member_id`=1) AND a.active=1
GROUP BY other_id
ORDER BY other_id DESC, `date sent` DESC
但我收到错误:
#1054 - Unknown column 'other_id' in 'on clause'
我正在使用as
密钥创建该列。有谁知道这里有什么问题?
谢谢。