Querying a second table based on 1st queries results
Posted: Fri Sep 02, 2011 8:02 pm
hi
I have 2 tables (members & friendship)
Members table columns:
--------------------------------------------
username | password | email | etc ....
--------------------------------------------
Person 1 xxxxxx x@x.com
person 2 yyyyyy y@y.com
Friendship columns:
---------------------------------------
username | friend | status |
---------------------------------------
person 1 person 2 friends
person 2 person 1 friends
person 1 person 3 pending
I want to query the friendship table: "SELECT friend FROM friendship WHERE username ='$_SESSION['myusername'];' AND status='friends' "
(so its basically getting the user names of anyone who is the logged in users friend)
And then use the returned user names to select their data from the members table.
Any help much appreciated!
^.^
I have 2 tables (members & friendship)
Members table columns:
--------------------------------------------
username | password | email | etc ....
--------------------------------------------
Person 1 xxxxxx x@x.com
person 2 yyyyyy y@y.com
Friendship columns:
---------------------------------------
username | friend | status |
---------------------------------------
person 1 person 2 friends
person 2 person 1 friends
person 1 person 3 pending
I want to query the friendship table: "SELECT friend FROM friendship WHERE username ='$_SESSION['myusername'];' AND status='friends' "
(so its basically getting the user names of anyone who is the logged in users friend)
And then use the returned user names to select their data from the members table.
Any help much appreciated!
^.^