I have three tables in the database, which are Training, Exercise and Exercise_Training .
I need to make SELECT
with INNER JOIN
and differentiate columns with the same name:
SELECT t.id AS tid, et.id AS etid, e.id as eid, t.data AS tdata, et.data
AS etdata, e.data as edata, *
FROM treino t
INNER JOIN exercicio_treino et
ON et.treino = t.id
INNER join exercicio e
ON e.id = et.exercicio;
What I would like to know is whether it is correct to do this or if you have a more practical way than typing all the columns in SELECT