0

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);

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.