Comparing two sets
Posted: Thu Feb 14, 2008 8:11 pm
I posted a similar problem in the database thread, but this is different and I think it's more of a PHP thing... I have two tables,
1. Groups
- country_codes
2. Sets
- country_codes
The country codes are comma delimited (i.e, US,UK,CA would be a record set). I want to find which ones have intersecting country_codes. So, if I select country_codes from "Groups" and it returns UK,US,CA - I want to then get all "Sets" that have country_codes values of any of the three. So if a record has AU,FI,US, it would return...
So, I'm thinking of just selecting the set I want, then selecting all groups and using array_intersect(), however I can't seem to figure out how to maintain the associated array. I've tried array_intersect_assoc, but then It's comparing against the whole associated array (which includes ID, Name and country_codes), not just the country_codes.
Anyone have any ideas? Or did I just confuse the hell of you.....
1. Groups
- country_codes
2. Sets
- country_codes
The country codes are comma delimited (i.e, US,UK,CA would be a record set). I want to find which ones have intersecting country_codes. So, if I select country_codes from "Groups" and it returns UK,US,CA - I want to then get all "Sets" that have country_codes values of any of the three. So if a record has AU,FI,US, it would return...
So, I'm thinking of just selecting the set I want, then selecting all groups and using array_intersect(), however I can't seem to figure out how to maintain the associated array. I've tried array_intersect_assoc, but then It's comparing against the whole associated array (which includes ID, Name and country_codes), not just the country_codes.
Anyone have any ideas? Or did I just confuse the hell of you.....