[英]mysql query for send and receiver messages for particular user
I want to make query to extract the send and receive messages under specific user.我想查询以提取特定用户下的发送和接收消息。 let suppose I tried to make understand question.
假设我试图提出理解问题。
there is list of users and when I click on the user all correspondence data should be come under this specific user.有用户列表,当我点击用户时,所有通信数据都应该在这个特定用户下。
The query I am using我正在使用的查询
SELECT id,post_id
, post_auth_user_id
, ask_user_id
, response_user_id
, message
, updated_at
FROM post_queries
WHERE (4 IN (ask_user_id,response_user_id)
OR 2 IN (ask_user_id))
OR (ask_user_id=4 AND response_user_id=0)
but this query is not give me appropriate result.但是这个查询没有给我合适的结果。
I want to all result like in this format.我希望所有结果都像这种格式。
id post_id post_auth_user_id ask_user_id response_user_id message updated_at id post_id post_auth_user_id ask_user_id response_user_id 消息updated_at
1 2 2 3 0 asking property 2020-10-10 14:09:14
3 2 2 3 2 yeh response hei 2020-10-10 15:19:14
If you want messages between two users -- say 2 and 4 -- you can use:如果你想要两个用户之间的消息——比如 2 和 4——你可以使用:
SELECT id, post_id, post_auth_user_id, ask_user_id, response_user_id, message, updated_at
FROM (ask_user_id = 2 AND response_user_id = 4) OR
(ask_user_id = 4 AND response_user_id = 2) ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.