When I query a mysql database in PHP, I can not figure out how to specify the table of the field in the result set.
For example, I would like to do the following:
$row = mysql_fetch_assoc($result);
$row["table.FIELD"];
But, can not figure out how. Surely, it is able to happen somehow.
EDIT: I have checked documentation, and have found nothing. I am not sure if I was understood at first… I know how to get the value of a field in a row from a result set. But, I would like to be able to get the value of a field in a row by specifying the name of the table in front of that field.
$row["FIELD"]; vs $row["table.FIELD"];
From the above line, I would like to do the latter.
Thanks,
Steve
You get it as
$row[field_name],And if you have two fields with same name but from different tables, You must add at least to one of them table.field AS somthing_else
will give
$row['id'],$row['t2_id']While if you don’t use the
ASyou will get only$row['id'](one value was lost).