MySQL Query - name of the result table

When I query the mysql database in PHP, I cannot figure out how to specify the field table in the result set.

For example, I would like to do the following:

$row = mysql_fetch_assoc($result);

$row["table.FIELD"];

But, I can’t understand how to do this. Surely this can happen somehow.

EDIT: I checked the documentation and found nothing. I'm not sure that 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 get the value of the field in the row by specifying the table name before this field.

$row["FIELD"]; vs $row["table.FIELD"];

From the above line, I would like to make the latter.

Thank,

Steve

+3
source share
3 answers

$row[field_name],
, , table.field AS somthing_else

SELECT t1.id,t2.id AS 't2_id' ....
...
...
var_dump($row);

$row['id'],$row['t2_id']

AS, $row['id'] ( ).

+2

$row ['FIELD'], , SQL.

print_r ($ row), , .

+1

The documentation explains how to do what you want, check out the examples.

-1
source

Source: https://habr.com/ru/post/1729322/


All Articles