解決策:
SELECT * FROM users WHERE NOT unique_id = "337244286" and unique_id in (
SELECT outgoing_msg_id FROm messages WHERE incoming_msg_id="337244286")
UNION
SELECT * FROM users WHERE NOT unique_id = "337244286" and unique_id in (select incoming_msg_id from messages WHERE outgoing_msg_id="337244286")