Suppose I have two tables, table1 and table2, like these:
table1
ID VALUE
0 2
1 8
4 3
table2
ID VALUE
1 9
3 5
0 1
How can I merge table1 and table2, such that the resulting table contains ID,VALUE1,VALUE2? Note: VALUE is different between table1 and table2. Also, the tables are unsorted and have different length, so there may be an ID in table1 that doesn't exist in table2 and vice-versa.
Resulting table
ID VALUE1 VALUE2
0 2 1
1 8 9
I have managed to select only the rows from table1 using this formula:
=INDEX(table1!$A$2:$B$4;MATCH(table2!$A2;table2!$A$2:$A$4;0))
In SQL, this could be easily done with:
SELECT table1.ID, table1.VALUE AS VALUE1, table2.VALUE AS VALUE2
FROM table1
INNER JOIN table2 ON table1.ID = table2.ID