I am developing a social website.I have an option called alerts which shows pending friend requests and unread messages.My query is following:
SELECT
sk_friends.frndship_from_user_id,
sk_messages.msg_from_user_id,
sk_messages.msg_text,
sk_messages.msg_date
FROM
sk_friends INNER JOIN sk_messages
WHERE
sk_messages.msg_to_user_id = '$user_id'
AND sk_friends.frndship_to_user_id ='$user_id'
AND sk_friends.frndship_status = 'pending'
AND sk_messages.msg_status='unread'
ORDER BY
sk_friends.fndship_date ASC,
sk_messages.msg_date ASC;
- sk_friends and ak_messages are tables.
- msg_from_user_id is the id of sender
- frndship_from_user_id is the id of the user who sends the request
- $user_id is the id of the login user
Each row data is appearing twice. I dont know why does it happen.