Jump to content


2 tables w/same fields compare?

  • Please log in to reply
1 reply to this topic

#1 dbrimlow

  • Members
  • PipPipPip
  • Advanced Member
  • 712 posts

Posted 22 March 2006 - 04:55 PM

I have two tables that are exactly the same in stucture.
table 1 gets populated by an auto dump sent via a custom 3rd party inhouse application. It works fine for 90% of our tables, but for one table the application is limited ... so I created a manual table to allow showing the same array as all the others.

table 2 is manually populated, to provide data in fields not usually included in table 1 dump.

I then have 2 sets of arrays that search both tables for the same content, and defines how it should display on the page in a description and in a bulleted amenities list. eg:

Table1 select includes -
if ($myrow[coop] == "COOPERATIVE") {
$description .= ", COOP";

if ($myrow[coop] == "CONDOMINIUM") {
$description .= ", CONDO";
if ($myrow[coop] == "CONDOP") {
$description .= ", CONDOP";
} etc., etc.

Table2 select includes:

if ($mytownhouse[bldg_type] == "townhouse") {
$description .= ", TOWNHOUSE";

if($mytownhouse[bldg_type] == "brownstone") {
$description .= ", BROWNSTONE";
} etc., etc.

This worked fine for the first year or so, it would provide data missing in table 1 with data from table 2.

But now, after a recent upgrade of our custom app., the dump is including some of the data that was missing from table1. So now, I am getting duplicate amenities.

These conditional arrays are both HUGE lines of text - easily spanning over 800 lines of code.

What I want know, is if there is an EASY way for me to exclude any duplicates among the tables from displaying, and set one table as the default source in the event of a duplicate?

I can compare each and every field and if both have data, ignore one or the other, but there MUST be a simple tables wide compare statement. Something like:

if (($myrow[$building()] !="") && ($mytownhouse[$building()] !="") {

$building()=$mytownhouse [$building()];

I don't know if I explained this coherently or not, and I don't think the above would work.


I am always amazed by no matter how much I know, I know I don't know as much as I thought I knew.  - D. Brimlow.

#2 wickning1

  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 22 March 2006 - 09:51 PM

Ideally this should be done in the MySQL query, but I don't know enough about your system to write it for you. It sounds like you are doing things the hard way - bigtime.

You could probably solve your problem quickly with the PHP function array_unique(), but again from your description I'm not clear on what you're after.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users