How can you access two identically-named columns in a MySQL LEFT JOIN query?
- by George Edison
I have two tables.
table_x:
id INT(11)
tag INT(11)
table_tags:
id INT(11)
name VARCHAR(255)
Then I use PHP to perform the following query:
SELECT * FROM table_x LEFT JOIN table_tags ON table_x.tag = table_tags.id
The only problem is: how do I access table_x.id and table_tags.id in the results?
Here is the PHP code:
$query = "SELECT * FROM table_x LEFT JOIN table_tags ON table_x.tag = table_tags.id";
$results = mysql_query($query);
while($row = mysql_fetch_array($results))
{
// how do I now access table_x.id and table_tags.id ???
}