I have been working as a data analyst for about 4 months now and the above is a very real question for me. The most recent way I've been taught to join is with the left join with the following example.
left join table1
on
table2.id = table1.id
left join table2
on
table3.table_id = table2.table_id
left join table4
on
table1.tablekey_id = table4.tablekey_id
Looking for the most efficient way to connect multiple tables to save time, if possible.
Thanks in Advance!
CodePudding user response:
- If it is only two tables of same columns and same datatypes, you can use union concept to join the tables.
- You can also join tables like this:
Tables: TableA, TableB
SELECT
column1,
column2,
column3
FROM TableA, TableB
WHERE TableA.id = TableB.id;
CodePudding user response:
You could certainly use a shorter alias for the table names and table fields.
Example:
Table 1 = alias t1
tablekey_id = tkid
So then it would t1.tkid
instead of having to type out table1.tablekey_id
.