i have two tables, looking like that. "Value1" is something like a 2nd key, ID + Value1 = "Primary" key, but its not in the table setup and the Value1 Field is missing in the 2nd table, so i can't join it.
But the first and 2nd table has always the same amount of rows and the exact same order!
Table 1:
ID Value1 Value2
10 1 100
10 2 200
20 1 250
30 1 150
30 2 125
Table 2:
ID Value 3
10 50
10 60
20 70
30 80
30 25
As the result i want to that the 2nd table is merged with the first table:
ID Value1 Value2 Value3
10 1 100 50
10 2 200 60
20 1 250 70
30 1 150 80
30 2 125 25
How to do this in SQL? Is it possible with a simple join/union, without creating new tables or something?
You can do this with a simple join statement
though I'd still suggest altering the tables to make them have primary and foreign keys that connect them properly.