Jump to content

Prefixed field names


nfvindaloo

Recommended Posts

Hi

I need to retrieve columns from the same table twice, using aliased names in the query.

When php retrieves a record i would expect ambiguous column names to be prefixed with the table name; ie: table.column, but mysql_fetch_assoc() seems to overwrite the ambigous columns so i only get the data from the last alias of the table.

There must be a way around this, is there a config option / runtime setting?

Thanks,
Nic
Link to comment
https://forums.phpfreaks.com/topic/5198-prefixed-field-names/
Share on other sites

Well, there isn't a way to do this in MySQL -- if you ask for 2 fields with the same name, you'll get back 2 fields with the same name, and the 2nd one will overwrite the 1st in the hash. Of course, if you get back an array of columns, this isn't a problem. If you want table.column, ask for table.column. The DB doesn't handle this for you. However, it is possible that PHP has a wrapper for this that I'm not aware of.
Link to comment
https://forums.phpfreaks.com/topic/5198-prefixed-field-names/#findComment-18849
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.