I have 2 tables:
'Users' Table
id username ---- -------- 0001 user1 0002 user2 0003 user3 0004 user4
'Friends' Table
user_id friend_id friend ------- --------- ------ 0001 0004 1 0002 0004 1 0005 0004 0
How do I display all user4 friends' name? if in friends table, friend column, 1 indicates they are friend, 0 indicate they are still not friend.
I use INNER JOIN, which looks like this:
SELECT users.username
FROM `users`
INNER JOIN `friends` ON users.id = friends.friend_id
WHERE friends.user_id = 0004
AND friend = 1;
But what I get is:
user4 and user4 instead of user1 and user2
Can help me?