greetings
I am asking for help with a problem I can't crack. I'm trying to use SQL to produce tbl_B (or a query showing the same results) from tbl_T and tbl_A. I'm pretty sure I could do this with VBA, but the processing would be slow (the tables I am actually working with are considerably larger than the samples shown below).
Here's the problem. tbl_T is a TEMPLATE table. The values of t1 to t5 are always 1, 2, 3, 4, 5 in some order. These values tell us how to select values from tbl_A. In the 1st row of tbl_T, the values 5, 2, 4, 1, 3 mean that from tbl_A, we select the values of a5, a2, a4, a1, a3 IN THAT ORDER, then write these values into tbl_B as shown. For each row in tbl_T, I run through all records in tbl_A, so the final tbl_B will have 160 records.
[tt]tbl_T tbl_A
T_ID t1 t2 t3 t4 t5 A_ID a1 a2 a3 a4 a5
1 5 2 4 1 3 1 67 23 100 42 87
2 2 3 1 5 4 2 17 118 62 87 15
3 3 4 5 1 2 3 38 21 29 8 16
... etc ... etc
20 5 3 1 2 4 8 111 10 98 22 42
[/tt]
[tt]tbl_B
B_ID T_ID A_ID b1 b2 b3 b4 b5
1 1 1 87 23 42 67 100
2 1 2 15 118 87 17 62
3 1 3 16 21 8 38 29
... etc
160 20 8 42 98 111 10 22
[/tt]
I am really stuck on how to assign values from tbl_A to template values in tbl_T. I'd appreciate any clues!
Vicky
I am asking for help with a problem I can't crack. I'm trying to use SQL to produce tbl_B (or a query showing the same results) from tbl_T and tbl_A. I'm pretty sure I could do this with VBA, but the processing would be slow (the tables I am actually working with are considerably larger than the samples shown below).
Here's the problem. tbl_T is a TEMPLATE table. The values of t1 to t5 are always 1, 2, 3, 4, 5 in some order. These values tell us how to select values from tbl_A. In the 1st row of tbl_T, the values 5, 2, 4, 1, 3 mean that from tbl_A, we select the values of a5, a2, a4, a1, a3 IN THAT ORDER, then write these values into tbl_B as shown. For each row in tbl_T, I run through all records in tbl_A, so the final tbl_B will have 160 records.
[tt]tbl_T tbl_A
T_ID t1 t2 t3 t4 t5 A_ID a1 a2 a3 a4 a5
1 5 2 4 1 3 1 67 23 100 42 87
2 2 3 1 5 4 2 17 118 62 87 15
3 3 4 5 1 2 3 38 21 29 8 16
... etc ... etc
20 5 3 1 2 4 8 111 10 98 22 42
[/tt]
[tt]tbl_B
B_ID T_ID A_ID b1 b2 b3 b4 b5
1 1 1 87 23 42 67 100
2 1 2 15 118 87 17 62
3 1 3 16 21 8 38 29
... etc
160 20 8 42 98 111 10 22
[/tt]
I am really stuck on how to assign values from tbl_A to template values in tbl_T. I'd appreciate any clues!
Vicky