mysql two table help
I need to search for a user and bring his details up only if he is in another user's friends list.
I have a user table with user_id, user_fname, user_sname etc.. and a friends table with friend_id, ur_id, their_id, approved
I have a ajax called php script to auto populate based on key pressing the letters that match the query.
Here is the query:
SELECT user_id, user_fname, user_sname, user_city, photo, email FROM users, friends WHERE ur_id = '$_SESSION[user_id]' AND user_fname LIKE '%$queryString2%' OR user_sname LIKE '%$queryString2%'
I seem to get all values, and doubles when I use this method, I dont think I can use a left join as I cant put the user_id and ur_id over each other.
Please can someone help me with this?
Thank you.