I have the following query:
SELECT a.column, b.column FROM a, b WHERE a.userid = b.id
Would like to be able to differentiate which column to display since the columns in both tables have the same name.
Clearly, if I use $row['column']
it only returns one of the values. I have tried $row['b.column']
to differentiate the table, but that did not return anything.
Use aliases:
SELECT a.column AS aColumn, b.column AS bColumn FROM a, b WHERE a.userid = b.id
You can name the column as you want using alias "AS", e.g:
SELECT a.column AS other_name, b.column AS b_column FROM a, b WHERE a.userid = b.id
Then you can call $row['other_name']
or $row['b_column']