janharders demonstrated that the column name (or alias if an alias is used) is one way to use the associative index in a mysql fetch. So, using mysql_fetch_assoc() the following example shows how you use the associative index name from your query. First, some simple tables for our example ...
TableA.id AS aid,
TableA.column2 AS acolumn2,
B.column2 AS bcolumn2,
INNER JOIN TableB AS B ON (TableA.id = TableB.id)
In your PHP while loop, you can refer to them like so ...
while($row = mysql_fetch_assoc($result))
$a_id = $row['aid']; // TableA.id
$column1 = $row['column1']; // TableA.column1
$acolumn2 = $row['acolumn2']; // TableA.column2
$bcolumn2 = $row['bcolumn2']; // TableB.column2
$column3 = $row['column3']; // TableB.column3
A number of techniques are demonstrated here. First, notice how both tables have some identical column names? We can use an alias on the column names so as to differentiate between the two. The columns are called ambiguous and by using an alias we can remove the ambiguity. We can also use an alias on a table name. You see that here when I use an alias for TableB. Now, whatever the column name, or alias name if used, is the index we use in our fetching control structure.