This is my query:
SELECT u.ProfilePic AS FriendPic,u.UserName AS FriendName,m.* FROM (SELECT PhotographerId FROM Messages WHERE UserId=? OR PhotographerId=? GROUP BY PhotographerId) AS m JOIN User AS u ON u.UserId=m.PhotographerId
I'm trying to make SQL query from table, - get last messages from all pairs of users with user ? as sender or recipient, and join them with users table to get names. I've managed to create something like this, but still want to ask if there is more simple
i want to fetch the photogrpher name, profile pic and last message of every user as we see in inbox..
table user: profile pic, username,user_id
message: userid, photographerid, message, timestamp
via Shifali
No comments:
Post a Comment