If you fetch the following data via an associative array in php:
SELECT thread.id, thread.title, thread.content, author.username, author.id
FROM thread INNER JOIN author
ON开发者_高级运维 author_id = author.id
How can you differentiate between author.id and thread.id?
$threads = select_Query('SELECT thread.id, thread.title, thread.content, author.username, author.id
FROM thread INNER JOIN author
ON author_id = author.id', $link);
You can use column aliases to resolve column name ambiguities:
SELECT thread.id AS t_id, thread.title, thread.content, author.username, author.id AS a_id
FROM thread INNER JOIN author
ON author_id = author.id
Then reference the aliases in your PHP array, as $row['t_id']
and $row['a_id']
respectively.
精彩评论