Re: [PHP4BETA] database queries with join

From: Date: Tue, 23 Nov 1999 19:13:14 +0000
Subject: Re: [PHP4BETA] database queries with join
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-6754@lists.php.net to get a copy of this message
Use column aliases : select x.a as a1, y.a as a2 from x,, y where x.b = y.b echo $row["a1"]; // x.a echo $row["a2"]; // y.a No ambiguity possible. Also useful when using aggregate functions such as count, sum, max ... to name the returned columns. Danny --- ----- Original Message ----- From: "Harold" <harold@salt.xgroup.de> Newsgroups: php4.beta Sent: Tuesday, November 23, 1999 7:52 PM Subject: [PHP4BETA] database queries with join > (php4 beta3 / apache 1.3.9 / redhat 6.0 / sybase 11.9.2) > > although i have not yet run into problems with database queries on more than > 1 table, i noticed an odd behaviour of php.. here is an example query: > > $query = sybase_query("select FIELD1.row1, FIELD1.row2 from FIELD1, FIELD2 > where FIELD2.row3 = FIELD1.row3"); > $row = sybase_fetch_array($query); > > echo $row[row1]; > echo $row[row2]; > > ---- > > there is no problems with the above, but since im using a join, wouldnt it > be better to use: > > echo $row[FIELD1.row1]; > echo $row[FIELD1.row2]; > > when the above is used, php returns a null. i havent come across a JOIN > where the field names are the same in two or more tables, but when it would > occur, which (field)value would echo $row[row1]; be taken from? > > > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net >

« previous php.version4 (#6754) next »