Re: PHP not parsing joined tables well

From: Date: Mon, 17 May 2004 20:26:49 +0000
Subject: Re: PHP not parsing joined tables well
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-186429@lists.php.net to get a copy of this message
Steve Douville wrote:
I'm got a query that is joining a few tables. select
    par.*, pla.*, pro.*, reg.*
    from parent par, players pla, registrations reg, programs pro
    where blah blah blah
Now, a result set is the same but I'm having trouble parsing it because I have column names that are identical in two of the tables. (A first_name in parent and first_name in players.) After getting the result set, PHP doesn't seem to like a reference to par.first_name to differentiate it from pla.first_name when I'm parsing the results. Even worse, in any given row, $resultArray['first_name'] only gives the first occurance which is the parent first name. The other "first_name" column seems unreferenceable. (is that a word?) Anyways, any help is appreciated. There are so many columns to pull, I'd hate to have to list them all out in the query. TIA.
you can use select *, pla.first_name pla_first_name, pro.first_name pro_first_name ... pla.first_name will be available as $resultArray['pla_first_name'] etc.

« previous php.general (#186429) next »