shortysbest Posted March 26, 2011 Share Posted March 26, 2011 I am trying to make a filter to show posts from mutual friends between you and the persons profile you're on, I have somewhat of an idea on how to write the mysql query (it needs to be just one query, not two(which would be the easy way of doing it)). the "friends" table has: "friend_1" and "friend_2" and the "posts" table: "to_id" and "from_id" The PHP variables would be: "$session" and "$id" id would be the users Id of the profile you're on. Thanks, any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/231808-finding-mutual-friends-and-selecting-information-from-separate-tables-mysql/ Share on other sites More sharing options...
monkeytooth Posted March 27, 2011 Share Posted March 27, 2011 Needs to be just one? Well that depends on how your data is structured and stored. But you could look into JOIN, INNER JOIN, LEFT JOIN.. to query multiple tables. But again in the end it depends on how your storing your data in your DB. You may have to query once for results, have PHP break down the results and then query again for the results of potential match. Again I dont know how your storing your data, and your know giving anyone here much to work with in that factor. No Database is created equally, unless your using a premade system, Wordpress or something to the effect there of, and even then. Also this is a mySQL issue and not a PHP issue. Wish I could be a bit more helpful but, theres just not much to work with. I could say SELECT * FROM jupiter WHERE mars LIKE '%saturn%' and say it applies to what your doing as it makes just as much sense to what your originally posting for code. Quote Link to comment https://forums.phpfreaks.com/topic/231808-finding-mutual-friends-and-selecting-information-from-separate-tables-mysql/#findComment-1192724 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.