I have three database tables: users, user_profiles and friends:
users
user_profiles
friends
Use:
SELECT f.username, up.* FROM USERS f JOIN USER_PROFILES up ON up.user_id = f.id JOIN FRIENDS fr ON fr.userb_id = f.id JOIN USERS u ON u.id = fr.usera_id WHERE u.username = ?
...assuming userb_id is the friend id.
userb_id