在 mysql 我有这个查询
SELECT m.*
FROM members m
RIGHT JOIN (SELECT
IF(`from member_id`=1, `to member_id`, `from member_id`) as other_id, text, `date sent`
FROM message
WHERE ((`from member_id`=1 AND `to member_id`=m.id) OR (`to member_id`=1 OR `from member_id`=m.id))
ORDER BY `date sent` DESC
LIMIT 1
) as t on 1=1
ORDER BY t.`date sent` DESC
我收到了这个错误:
Unknown column 'm.id' in 'where clause'
如何在子查询选择语句中传递成员列值?
我正在创建这个子查询,因此它评估为 1 行,然后我想将它附加到外部选择语句的右侧。
谢谢。