如果您通过php中的关联数组获取以下数据:
SELECT thread.id, thread.title, thread.content, author.username, author.id
FROM thread INNER JOIN author
ON author_id = author.id
如何区分author.id和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);
答案 0 :(得分:2)
您可以使用列别名来解决列名歧义:
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
然后分别引用PHP数组中的别名,分别为$row['t_id']
和$row['a_id']
。