How to get data from 3 tables with INNER JOIN in a performatic way

-1

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

    
asked by anonymous 27.10.2017 / 06:46

2 answers

0

The way you're doing the right thing to do, I advise you to do is to put more meaningful names to the alias, alias is the name given to this alias of the table, to make your call easier.

SELECT column_name AS alias_name
FROM table_name;

More Information

    
30.10.2017 / 17:09
-2

To get all the columns in a select you should do so:

SELECT * FROM ...

but it is not advisable .

    
27.10.2017 / 08:40