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 Quote Link to comment Share on other sites More sharing options...
jim_keller Posted November 24, 2010 Share Posted November 24, 2010 echo count( array_intersect($array1, $array2) ); Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
RON_ron Posted November 24, 2010 Author Share Posted November 24, 2010 Thanks mate! Quote Link to comment 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.