SQL query for fetching friend list
- by Bhavyanshu
I need help with SQL query.
I have two tables. One is users and other one is userfriends
users table:
aid email firstname
1 example@mail.com example
2 example2@mail.com example2
3 example3@mail.com example3
4 example4@mail.com example4
userfriends tables:
reqid email friendemail status
1 example1@mail.com example2@mail.com 1 (example1 is frnds with example2)
2 example2@mail.com example4@mail.com 2 (example2 request pending)
3 example3@mail.com example1@mail.com 1 (example1 is frnds with example3)
4 example4@mail.com example1@mail.com 1 (example1 is frnds with example4)
So when status is 2 the add request is pending and at status 1 they are friends. What i want is that i want to retrieve the complete friendlist for user example1. I want to pull out names from users table for corresponding output from previous query to display as friendlist.