Ok I have a two tables one is called users and the other table is called friends. I am trying to select the FName of a friend. When I add a new friend to the friend table the field names are user_id, friend_id and user_name. The user_id is the id of person getting the friend, the friend_id is the person that is being added as the friend and the user_name is the user_name of the person getting the friend (user_id and user_name are pretty much the same thing).
I want the query to select the FName of the friend from the users table. The friend_id corresponds to a user_id from the users tables.
I would want the query to be something like this:
$query = "SELECT FName from users, friends WHERE friends.friend_id=users.user_id AND WHERE friends.user_name = '$_SESSION[Username]' ";
I think I would almost have to do this in two queries, one query to select the friend_id and then run the $query. The query I would use to select the friend_ids is:
$queryfriend = "SELECT friend_id from friends Where user_name = '$_SESSION[Username]'";
How would I integrate those two queries together to get my desired result???
So in english the query is trying to say Select the first name of the friend who's id equals the id that was assigned when the user registered and only list the user's friends who has the username which is trying to view all their friends.
I'm using MySQL and I can't get this query to work. Please help?? I tried your suggestion earlier and it wouldn't work.