Let’s say I have 10 tables, each tableN has an ID and a ValueN.
I want to combine all of them into one table which has the following content:
ID Value1 Value2 Value3 ...
The IDs are unique but each table can have any number of records, so a result row can be:
001 3.1 Null 4.6 ...
I know how to do this simple query when there are only 2 tables. But don’t know the best way to compare the ID values from 10 tables.
Say you have 3 tables (or any number of tables)
You can use a query like this to make sure that you get all possible data from all tables:
The result of which is:
Basically, it’s just a succession of
LEFT JOINon each table, all joined by the union of all possible IDs accross all tables: