differentiating between identical fields

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
delpi767
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 11:46 am

differentiating between identical fields

Post by delpi767 »

if I am joining two tables (golfers and residents) that both have the column "posted" how do I differentiate between these columns in php?

If I want to reference the column posted from both tables how do I do so?

Thanks,

Mac
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: differentiating between identical fields

Post by josh »

Column aliases
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: differentiating between identical fields

Post by McInfo »

If you don't assign aliases to each returned field in your query, you will have to fetch the result as a numeric array with a "fetch_row" function (for example, mysql_fetch_row()). You will not be able to fetch an associative array because there will be key conflicts which will be silently resolved by overwriting values.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: differentiating between identical fields

Post by califdon »

delpi767
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 11:46 am

Re: differentiating between identical fields

Post by delpi767 »

Thank you gentlemen!
Post Reply