[nycphp-talk] comparing arrays to build query?
Kristina Anderson
ka at kacomputerconsulting.com
Sat Jun 7 22:22:10 EDT 2008
OK, this really has me flummoxed. I'm not sure if I'm going about this
the right way.
I have three tables, an Employer table, a Provider table and a Jobs
table. Each Provider (worker) has up to nine zip codes and a possible
metro area which contains all the zip codes in their city which is
their "service area".
When they log on, I need to display only the Jobs in any of their zip
codes.
In the Jobs table, there is a remote zip field (remzip) and if that has
a value, that is the zip where the job is, otherwise we use the zip
field in the Employers table.
I've built two arrays one by
"SELECT * FROM Providers INNER JOIN Employers ON Jobs.empid =
Employers.EmpID ";
which gives me both the remzip and zip fields and the jobid field.
And one by querying the database for all the zips in the service area
of that particular Provider and dumping them all into an array.
So now I have these two arrays I can compare...is there an easier way
to do this or ... ?
I need to compare these two arrays and if any value from array 2 is in
array 1, pull out the entire row by jobid from the database and display
it.
Thanks in advance,
---- Kristina
More information about the talk
mailing list