RON_ron Posted November 24, 2010 Share Posted November 24, 2010 How to check if a result of a database match with a result of another database. How do this? E.g. In DatabaseA holds a column called usernames. In DatabaseB holds a column called banned. Is it possible to match results of an Array with an Arrary of results of another database and COUNT the matching results? E.g. In DatabaseA holds 4 columns and the records are pulled in as an array. Science Geography Accounting Agriculture In DatabaseB holds 4 columns and the records are pulled in as an array. Geography French Accounting Science THE RESULT should echo = 1 Link to comment https://forums.phpfreaks.com/topic/219716-match-results/ Share on other sites More sharing options...
jim_keller Posted November 24, 2010 Share Posted November 24, 2010 echo count( array_intersect($array1, $array2) ); Link to comment https://forums.phpfreaks.com/topic/219716-match-results/#findComment-1139031 Share on other sites More sharing options...
jim_keller Posted November 24, 2010 Share Posted November 24, 2010 Although, unless you have a reason to pull these all into arrays, you should just do it in your query (I'm guessing at your field names). It will be much more efficient, especially as the tables grow: SELECT * FROM banned, usernames WHERE banned.user_id = username.user_id Link to comment https://forums.phpfreaks.com/topic/219716-match-results/#findComment-1139038 Share on other sites More sharing options...
RON_ron Posted November 24, 2010 Author Share Posted November 24, 2010 Thanks mate! Link to comment https://forums.phpfreaks.com/topic/219716-match-results/#findComment-1139048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.