Search code examples
mysqlinner-join

How to SELECT a common parameter and display in export using INNER JOIN?


The common parameter in all tables is ID (primary key). Now I would like that the ID also appears in the export and at best then arrange all entries ascending with the ID. But this seems to be not possible. PhpMyAdmin gives the error message #1052 - Field 'ID' in field list is not unique.

Is there a way to export the ID as well?

My function has the following structure:

SELECT name, age, date, ID FROM table t1 INNER JOIN table t2 ON t1.ID = t2.ID INNER JOIN table t3 ON t2.ID = t3.ID ORDER BY t1.ID ASC;

Table 1 ID name

Table 2 ID age

Table 3 ID date


Solution

  • Your SELECT ID part seems vague. Perhaps be explicit and state t1.ID.