Re: mysql/php how to retrieve the right column with 2 columns of the same name

From: Date: Thu, 04 Jul 2002 09:54:41 +0000
Subject: Re: mysql/php how to retrieve the right column with 2 columns of the same name
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-105410@lists.php.net to get a copy of this message
thx Jason, now I understand the use of aliases in select queries. Good ID:-) Wilbert ----- Original Message ----- From: "Jason Wong" <php-general@gremlins.com.hk> To: <php-general@lists.php.net> Sent: Thursday, July 04, 2002 11:38 AM Subject: Re: [PHP] mysql/php how to retrieve the right column with 2 columns of the same name > On Thursday 04 July 2002 17:23, Wilbert Enserink wrote: > > 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?? > > Try to limit your select statement, instead of SELECT *, use > > SELECT colA, > colB, > tablA.samenamecolA, > tablB.samenamecolA, etc > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > Love is the process of my leading you gently back to yourself. > -- Saint Exupery > */ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php ------------------------- Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl info@pdd.nl -------------------------

« previous php.general (#105410) next »