たとえば、2 つのテーブルを作成しました。
表 1: t5zgu_property_message
msg_from msg_to subject message
57 42 xxxxx xxxxxx
57 42 xxxxx xxxxxx
57 42 xxxxx xxxxxx
42 42 xxxxx xxxxxx
表 2: t5zgu_users
id username
42 Jack
57 Rocky
このように出力したい:
msg_from msg_to subject message msg_from msg_to
57 42 xxxxx xxxxxx Rocky Jack
57 42 xxxxx xxxxxx Rocky Jack
57 42 xxxxx xxxxxx Rocky Jack
42 42 xxxxx xxxxxx Jack Jack
私の現在のクエリは次のとおりです。
SELECT
t5zgu_property_message.id,
t5zgu_property_message.msg_from,
t5zgu_property_message.msg_to,
t5zgu_property_message.subject,
t5zgu_property_message.message,
t5zgu_users.username as msg_from
FROM
t5zgu_property_message,
t5zgu_users
WHERE
t5zgu_property_message.msg_from = t5zgu_users.id
ORDER BY t5zgu_property_message.id DESC
このクエリはmsg_fromで完璧に機能し、正しい出力が得られますが、msg_toの書き方がわかりません。
アイデアや提案はありますか?ありがとう。