I have two query results from different tables like below.
ID F1 F2 F3 ID F3 F4 F5
S1 d11 d12 d13 S2 d23 d24 d25
S2 d21 d22 d23 S3 d33 d34 d35
S3 d31 d32 d33 S4 d43 d44 d45
ID and F# are field names, the others are values.
I want to get a new result in a similar form to the following from the results above.
ID F1 F2 F3 F4 F5
S1 d11 d12 d13
S2 d21 d22 d23
S2 d23 d24 d25
S3 d31 d32 d33
S3 d33 d34 d35
S4 d43 d44 d45
Is this possible in SQL? I'm programming in VBA with ADO.
I've never done such a task before.
Edit: The fields of the first two tables are dynamic. I can't predict how many there are or what they are.