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
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:
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) ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.