mysql/php how to retrieve the right column with 2 columns of the same name
| From: | Wilbert Enserink | Date: | Thu, 04 Jul 2002 09:23:16 +0000 |
| Subject: | mysql/php how to retrieve the right column with 2 columns of the same name | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105404@lists.php.net to get a copy of this message | ||
Hi all,
I have to tables A and B.
They boyh have a column with the same name.
Now, I wrote this MySQL statement performing a left join.
This results in a data set with rows consisting of 2 columns of the same name, in which the date is
stored when the record was last altered. This column is called "last_altered".
Later on in my script I'm calling the value of this column with php.
$query="select * from tblA LEFT JOIN ....";
$resultID=mysql_query($query);
while ($result_row=mysql_fetch_array($resultID))
{
echo "$result_row[column with the same name]";
}
Well, this works without any php or mysql errors, but it is giving me the data back of that column
wich I don't wanna have...It returns the "last_altered" date of tblB in stead of
tblA.
A solution might be te exclude the second column (the wrong one) from the select statement in the
query. This is a MySQL adjustement. Anybody knows how this can be done??
Maybe there are also PHP solutions which I don't know of...?
thx
Wilbert Enserink
-------------------------
Pas de Deux
Van Mierisstraat 25
2526 NM Den Haag
tel 070 4450855
fax 070 4450852
http://www.pdd.nl
info@pdd.nl
-------------------------