php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21589 mysql_fetch_assoc() and duplicate field names
Submitted: 2003-01-11 16:18 UTC Modified: 2003-01-11 16:41 UTC
From: rabidvan at mail dot ru Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.2.3 OS: Windows XP and 2000
Private report: No CVE-ID: None
 [2003-01-11 16:18 UTC] rabidvan at mail dot ru
I have 2 tables:
[table1]
  BLOCK_ID mediumint(8)
  SUB_ID mediumint(8)
  ...
[table2]
  BLOCK_ID mediumint(8)
  ...
I call query:
  SELECT * FROM table1 a, table2 b
  WHERE a.sub_id=b.block_id AND a.block_id=1;
It works well.
But when I use same query without aliases:
  SELECT * FROM table1, table2
  WHERE table1.sub_id=table2.block_id AND a.block_id=1;
In this case mysql_fetch_assoc() returns only 1 field BLOCK_ID and it's table2.BLOCK_ID.
I think it's a bug in mysql_fetch_assoc() because MysqlFront returns table1.BLOCK_ID as BLOCK_ID and table2.BLOCK_ID as BLOCK_ID_1

Thank you.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-11 16:24 UTC] georg@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.


 [2003-01-11 16:41 UTC] pollita@php.net
That is not a function of the mysql client libraries, MysqlFront does some automagic renaming of the fields.  

When doing queries which return ambiguous identically named fields consider using the "as" opperator in your SQL statement.  For more information see the mysql documention at:

http://www.mysql.com/
 [2003-01-11 16:49 UTC] rabidvan at mail dot ru
Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC